I've been trying to make a motion detector and so far it's gone pretty well. I've recently been working on rotating the part to match the player's rootpart direction, but I just can't seem to get the script to work. The only thing the output says is "Workspace.player.Tool.Handle.Part.SurfaceGui.Background.Rotate,Line 8" The part that I'm scripting is inside a tool, so that may be a problem.
local player = game:GetService("Players").LocalPlayer local part1 = player.Character.HumanoidRootPart local direction = part1.CFrame.lookVector local heading = math.atan2(direction.x, direction.z) local head = math.deg(heading) while true do script.Parent.Rotation = script.Parent.Rotation + UDim2.new(head) wait() end