Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Any way to make the player rotate towards the mouse?

Asked by 4 years ago

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.

0
You should at least have coded the function you wanted, we are here to fix your mistakes not just outright make scripts. Fl3eandFlo3e 18 — 4y
0
It's called I'm asking if there is a way to do it. DejaSketch 84 — 4y
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. GalenIII 0 — 4y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
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)
Ad

Answer this question