Help with making a part always looking at the player (there orientation changes to players)

i dont have one no ;;;;;;;;;;;;;;;;;;;;;

You can use plr.Character.Humanoid.Running to detect movement?

local Plr = game.Players.LocalPlayer.Character
while true do
	print("HI FRIENDS")
	wait(0.01)
	Plr.Character.Humanoid.Running:Connect(function()
		script.Parent.CFrame.lookAt(script.Parent.CFrame, Plr.Character.HumanoidRootPart.CFrame)
		print("SOY AMIGO SOS SUSIE")
	end)
end

by the way it p[rints nothing

No, dont do the while true loop, that defeats the whole purpose of the event

local Plr = game.Players.LocalPlayer.Character
print(“HI FRIENDS”)
wait(0.01)
Plr.Character.Humanoid.Running:Connect(function()
script.Parent.CFrame.lookAt(script.Parent.CFrame, Plr.Character.HumanoidRootPart.CFrame)
print(“SOY AMIGO SOS SUSIE”)
end)

doesnt work

Waittttttttttttttttttttttt. Is the code in a local script or server script?

local script i believe ;;;;;;;;;;;;;;;;

Instead place the local script in the StarterPlayer>StarterCharacterScripts
image

then the script:





 local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local dummy = --the path to the dummy that you want to look at the player
humanoid.Running:Connect(function()
dummy.HumanoidRootPart.CFrame = CFrame:lookAt(dummy.HumanoidRootPart.Position, root.Position)

end)

Ima go now tell me if there is any error and also make sure the dummy is un anchored

by the way the dummys name is a space since roblox was stupid and made text above the head if it had a name forcefully

Players.SakDevRblx.PlayerScripts.LocalScript:11: invalid argument #1 to ‘lookAt’ (Vector3 expected, got table)

Can you show me a picture of your current code because it should work is you followed everything right

Now can you show me a picture of the output when u run it?

image

I don’t know if this is the issue but, it’s CFrame.lookAt() not CFrame:lookAt() as seen in your script.

1 Like

thanks man ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

by the way its really laggy. how do i fix the lag? like a smoother thing it turns once ever 2 seconds. also when player dies it breaks

The lag comes from it being tied to the “Running” function on the Humanoid, which only fires every time the Movement Speed of the Humanoid changes, to fix the lag you’d have to detect when the “MoveDirection” property of the Humanoid changes, here’s some sample code:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
local dummy = workspace.dummy

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if humanoid.MoveDirection.Magnitude > 0 then -- if it's under or is 0, the humanoid is NOT receiving movement inputs.
		dummy.HumanoidRootPart.CFrame = CFrame.lookAt(dummy.HumanoidRootPart.Position, root.Position
	end
end)

This of course, is just a mockup, it doesn’t fix that if you die it breaks.

1 Like