Need help making the player point to where the mouse is pointing

Hello, I’m new to scripting and I’m currently making an isometric game in Roblox and I’m trying to make the player point to where the mouse is pointing but I’ve had no luck
what i was trying to achieve is the player will turn to wherever the players mouse is pointing on z axis

Here’s a solution. Get the mouse position using .Hit. This can be done on a localscript (StarterCharacterScripts)

local RS = game:GetService("RunService")

local player = Players.LocalPlayer
local character = script.Parent
local hrp = character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()

RS.RenderStepped:Connect(function()
    local hrpPos = hrp.Position
    local mousePos = mouse.Hit.Position

    hrp.CFrame = CFrame.new(hrpPos, Vector3.new(mousePos.X, hrpPos.Y, mousePos.Z))
end)

If you want it to be smooth, you need to use AlignOrientation, if you want I can help you with that. I haven’t tested this code, tell me how it works.

1 Like

This is great, thank you!
i dont need anything too fancy so this should do the job fine

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.