Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make the humanoid root part follow the direction of the mouse?

t=Instance.new("BodyGyro",script.Parent.Parent.Character.HumanoidRootPart) t.maxTorque = Vector3.new(0,math.huge,0) while true do Character=script.Parent.Parent.Character Player=game.Players.LocalPlayer mouse=Player:GetMouse() Character.HumanoidRootPart.BodyGyro.CFrame = CFrame.new(Character.HumanoidRootPart.Position,mouse.Hit.p)

wait() end

This is what I tried but it makes it rotate slow and it will go to the direction of the mouse but the it will go the fastest route instead of following the mouse exactly.

1 comment

0

Could you put your code into a code block pleaseee.

1 answer

✓ Accepted answer

To do this I would use CFrame rather than BodyGyro.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local root = char:WaitForChild('HumanoidRootPart')

local mouse = plr:GetMouse()

game:GetService('RunService').RenderStepped:Connect(function()
	root.CFrame = CFrame.new(root.CFrame.p,root.CFrame.p 
		+ Vector3.new(mouse.hit.lookVector.x,0,mouse.hit.lookVector.z))
end)

1 comment

0

Thanks, could you explain what Renderstepped is while you're at it ;3

This discussion is preserved as it was. New answers, comments, and votes are closed.