I'm making a top-down game and am using this script to make the player face the mouse: (Local script in StarterCharacterScripts)
local Player = game.Players.LocalPlayer local Character = Player.Character local Root = Character.HumanoidRootPart local Mouse = Player:GetMouse() local RunService = game:GetService("RunService") RunService.RenderStepped:Connect(function() local RootPos, MousePos = Root.Position, Mouse.Hit.Position Root.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z)) end)
However, this makes the player spin rapidly and rotate even when completely still. Video example here: https://www.youtube.com/watch?v=mfO7S7niV4g
i dont see whats a problem with
local Player = game.Players.LocalPlayer local Character = Player.Character local Root = Character.HumanoidRootPart local Mouse = Player:GetMouse() local RunService = game:GetService("RunService") RunService.RenderStepped:Connect(function() local RootPos, MousePos = Root.Position, Mouse.Hit.Position Root.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z)) end)
this is my full code replicating this in a empty baseplate
local RunService = game:GetService("RunService") local camera = workspace.CurrentCamera local player = game.Players.LocalPlayer local Root = player.Character:WaitForChild("HumanoidRootPart") local Mouse = player:GetMouse() local CAMERA_OFFSET = Vector3.new(-1,90,0) local CframeLerp = CFrame.new() camera.CameraType = Enum.CameraType.Scriptable local function onRenderStep(DT) -- Check the player's character has spawned if player.Character then local playerPosition = player.Character.HumanoidRootPart.Position local cameraPosition = playerPosition + CAMERA_OFFSET local RootPos, MousePos = Root.Position, Mouse.Hit.Position Root.CFrame = CFrame.LookAt(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z)) camera.CFrame = CFrame.new(cameraPosition, playerPosition) end end RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
maybe you have something interfering with the script above