How to make this script replicate to a server?

i have a script that uses RenderStepped to make a smooth pet follow system, but a problem that this doesnt replicate to a server so no one except local player see the pets. Is there a way i can make it replicate to a server? Or maybe i can make smooth pet follow using server script?

I tryed Firing server and server will change position of pet, but its no more smooth as without it

I’m not sure if this works, but on the server give the player network ownership of the pet through Part:SetNetworKOwner(Player), no manual replication to the server needed.

One thing you could do is make a value and find a way to make the value the name of the owner (just something like Owner.Value = game.Players.LocalPlayer.Name) and use this script:

local NewPet = script.Parent

NewPet.CanCollide = false

local PetPos ="BodyPosition", NewPet)
local PetGyro ="BodyGyro", NewPet)
PetGyro.MaxTorque =,400000,400000)
local Owner = --insert that value here

while(1) do --This is how long it takes to update when the player moves 
     local OwnerObj = workspace:WaitForChild(Owner)
     local OwnerPos = OwnerObj.HumanoidRootPart.Position
     local StopAt = ((OwnerPos - NewPet.Position).magnitude - 5) * 1000 --This keeps the pet from falling into the ground
     PetPos.P = StopAt
     PetPos.Position = OwnerPos +,10,0)
     PetGyro.CFrame = OwnerObj.HumanoidRootPart.CFrame

I tryed this, but to set network owner i need part to be not anchored and if i will unanchor it for server and other players pet will be undermap for some reason and for local player pet is good, but once pet is absolutely underworld for server pet dissapears for everyone. Is there way i can bypass this anchor thingy?

Could you please provide more detail on what you are trying to say?

It needs to be un-anchored on both the client and server for it to replicate, since it has to be movable by physics on both machines. If you give the player, who has the pet, network ownership of the pet, then it will be automatically replicated to the server and then to other players. If its position is being updated in a RenderStepped, then there’ll probably be no chance of it falling out of the world.

Also, you shouldn’t really use RenderStepped because not using it accordingly can cause performance issues – RenderStepped should only be used for anything that should be updated before a frame is rendered (drawn), but the only things you’d use this for is either updating the player’s character or their camera. RunService.Stepped is a more appropriate function because you’d use this for when you’re affecting / altering physics, since this event fires before the physics update step of frame

You probably could lighten the load on the client by using BodyMovers instead of RunService.Stepped and RunService.RenderStepped

i have no idea why this happening but for server pet falls underground and then it dissapears for everyone…