I’m working on a script that forces the player (if they have the tool equipped) to temporarily look at the humanoid that they click on. I would also like them to still be able to walk around while looking at the target. Unfortunately, this is the following result:
Code Segment:
aimEvent.OnServerEvent:Connect(function(player, target, aiming, char, hum)
aiming = true
local targetRoot = target:WaitForChild("HumanoidRootPart")
local charRoot = char:WaitForChild("HumanoidRootPart")
print("Target:", targetRoot.Parent)
print("Player:", charRoot.Parent)
local aimCoroutine = coroutine.create(function()
runService.Heartbeat:Connect(function(step)
if aiming then
charRoot.CFrame = CFrame.lookAt(charRoot.Position, targetRoot.position)
end
end)
end)
coroutine.resume(aimCoroutine)
end)
From what I can see, I think it’s just because it needs to be faster or something like that. Your character is moving quicker than the function runs. I personally don’t know how to fix that but I assume that is the cause.
What script type is it handled on? Local or Server
On a server side it will always set your characters position to its last pinged position which on heartbeat would not work too well
I would, but if I remember correctly, (I likely don’t) other players can’t see client sided character movement. Do you know if there’s any way of doing the movement on the client and still having it be visible to others?