What do you want to achieve? Keep it simple and clear!
I want the character to look at the mouse.
What is the issue? Include screenshots / videos if possible!
Whenever I run my script it just hits me with "attempt to index nil with ‘Character’.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I read the “Facing Toward a Point” section on Understanding CFrames.
Link: CFrames | Documentation - Roblox Creator Hub
I only have a normal script in the workspace, this is the code inside of it.
wait(2)
local player = game.Players.LocalPlayer
local Character = player.Character
local Mouse = player:GetMouse()
while wait() do
local StartPosition = Character.HumanoidRootPart.Position
local TargetPosition = Mouse.Hit.p
Character.HumanoidRootPart.CFrame = CFrame.new(StartPosition, TargetPosition)
end
My code now looks like this but my character is still freaking out for some reason.
wait(2)
local player = game.Players.LocalPlayer
local Character = player.Character
local Mouse = player:GetMouse()
while wait() do
local StartPosition = Character.UpperTorso.Position
local TargetPosition = Mouse.Hit.p
Character.UpperTorso.CFrame = CFrame.new(StartPosition, TargetPosition)
end