Im making a pet that follows the player and im using a while loop with a wait() to update the body position, Is this the best way to do this? Also should I update the body position on the client or server?
1 Like
you can use a localscript for this. as you can test this in your game. use a local script after making a brick containing a BodyPosition (Name the brick “Part” if its not already at instanciating) and put this in a local script located in starterPlayerScripts:
repeat wait()
if game.Players.LocalPlayer.Character then
workspace.Part.BodyPosition.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(3,2,0)
end
until nil
this is just for test so don’t worry about the infinite yield. once you’ve done this and swapped to server view by clicking this icon under “Test”:

it’ll change to “Current: Server”. now just take the Move tool from Model → move or press Ctrl + 2 and click on your character and move it. as you can see the brick will move to the character not only in the client but also in the server
1 Like