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

How to make the character face your mouse smoothly?

character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.CFrame.Position, hit.Position)

I use the code above and it works fine, but when I jump or move, and when this code runs, it will do this: https://streamable.com/18ytex It seems like it's not updating the position quickly enough, and that's why it looks like I'm lagging or going back.

1 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)

2 comments

0

Not the answer I was looking for, I wanted to make it only face the mouse once, not continously.

0

You're literally contradicting your own question; be concise.

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