I am trying to make a humanoid move with the mouse cursor in Roblox Studio.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tower = getTower(towerOneIndex):Clone()
tower.Parent = workspace.Map1.Towers
local towerHum = tower:WaitForChild("HumanoidRootPart")
mouse.Move:Connect(function()
print("moved")
towerHum.CFrame = mouse.Hit
print(towerHum.CFrame)
print(mouse.Hit)
end)
The 'tower' humanoid spawns on the map but does not follow the mouse
The final two print functions return the same value but despite the tower humanoid CFrame being updated the humanoid does not movve
Here is what I am getting out of this:
The tower’s HumanoidRootPart is probably still moving, but the rest of the tower might not be. If the tower is a model, you can use :MoveTo() on it to move the whole thing. Example code:
mouse.Move:Connect(function()
print("moved")
tower:MoveTo(mouse.Hit)
print(towerHum.CFrame)
print(mouse.Hit)
end)
I am writing this on a school iPad, so I am not able to test this or provide documentation links (they blocked roblox.com), but please tell me if it works!