#How to make a part face you (client-sided)
1 messages · Page 1 of 1 (latest)
I think like this in a local script
local _,ry= CFrame.lookAt(part.Position, playerPosition):ToOrientation()
part.Orientation=Vector3.new(0,ry*180/math.pi,0)
** You are now Level 5! **
how do I get the player's position?
you could do LocalPlayer.Character.Head.Position
LocalPlayer shows up with a red line underneath
you will have to put this at the top
local Players=game:GetService("Players")
local LocalPlayer=Players.LocalPlayer
you potato.
still doesn't work
you also need to put the code thats making it face the player inside a loop so it will keep running
you can use RunService for that it you want it to be accurate every frame:
local RunService=game:GetService("RunService")
RunService.RenderStepped:Connect(function()
...
end)
or you can just do like
while task.wait() do
...
end
I'm trying to do the RunService one and it isn't working
** You are now Level 1! **
this is what I have in the localscript:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local RunService = game:GetService("RunService")
local _,ry = CFrame.lookAt(script.Parent.Position, LocalPlayer.Head.Position):ToOrientation()
RunService.RenderStepped:Connect(function()
script.Parent.Orientation = Vector3.new(0,ry*180/math.pi,0)
end)
you need both these lines running every frame so that it knows which direction to look towards the player
RunService.RenderStepped:Connect(function()
local _,ry = CFrame.lookAt(script.Parent.Position, LocalPlayer.Head.Position):ToOrientation()
script.Parent.Orientation = Vector3.new(0,ry*180/math.pi,0)
end)
also if you're putting the script inside the part you want to rotate, make it a regular script
like this
and in properties change legacy to client
and are there any errors
change "LocalPlayer.Head"
to "LocalPlayer.Character.Head"
you're welcome