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

Any way to make the player rotate towards the mouse?

Is there a way to make an R6 (specific) player rotate and point to where the mouse is on screen? Can't think of any examples, but I think I explained it in the best way I could.

3 comments

0

You should at least have coded the function you wanted, we are here to fix your mistakes not just outright make scripts.

0

It's called I'm asking if there is a way to do it.

0

Please be helpful instead of say you're here to correct mistakes. There needs to be a sense of education instead of straight up cutting off a question just because the function was not already detailed for you.

1 answer

✓ Accepted answer
local Player = game:GetService("Players").LocalPlayer
local Cursor = Player:GetMouse()

Cursor.Move:Connect(function()
    local Character = Player.Character or Player.CharacterAdded:Wait()
    local Humanoid = Character:WaitForChild("Humanoid")
    if (Humanoid:GetState() ~= Enum.HumanoidStateType.Dead) then
        local CursorPosition = Cursor.Hit.p
        local CenterPosition = Character.Torso.Position
        local LookVector = Vector3.new(CursorPosition.X,CenterPosition.Y, CursorPosition.Z)
        Character.Torso.CFrame = CFrame.new(CenterPosition, LookVector)
    end
    Humanoid.AutoRotate = false
end)

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