Parts stop following player after a while?

Hi, I have a part following system that works like this: the parts are positioned in a circle around the player in runservice.Heartbeat, and they rotate around the player at the same time. When you have to “equip” one of these parts, an event is fired to the server and the server sets the network ownership of the parts to the player, that’s basically it.
The problem is that the parts work, they follow the player and rotate around it at the same time, but after a while they stop following the player and fall off the map.

I have a Localscript in PlayerScripts:

runService.Heartbeat:Connect(function(step)

		if #plr.Character:FindFirstChild("Items"):GetChildren() > 0 then

			for i, itemPart in plr.Character:FindFirstChild("Items"):GetChildren() do

				local angle = (i * 2 * math.pi) / #plr.Character:FindFirstChild("Items"):GetChildren()
				local positionOnCircle = Vector3.new(math.sin(angle + counter), 0, math.cos(angle + counter))

				itemPart.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position + positionOnCircle * (4 * plr.Character.Humanoid.HeadScale.Value))
				itemPart:WaitForChild("BillboardGui", 2).Icon.UIScale.Scale = (0.16 * plr.Character.Humanoid.HeadScale.Value) / (#plr.Character:FindFirstChild("Items"):GetChildren() / 3)

				counter += (0.5 / (#plr.Character:FindFirstChild("Items"):GetChildren())) * step
			end
        end
end

and inside that localscript I have a while loop that every 10 seconds fires an event to the server to “update” the parts, (I tried this because I thought it would work but apparently it doesn’t)

event.OnServerEvent:Connect(function(plr)
	for _, item in plr.Character:FindFirstChild("Items"):GetChildren() do
		if item:IsA("BasePart") then
			item:Destroy()
		end
	end
	
	local itemsFolder = plr.Character:FindFirstChild("Items")
	
	for _, item in plr.Items:GetChildren() do
	
		local newItemPart = game.ReplicatedStorage.Items[item.Name]:Clone()
		newItemPart.Parent = itemsFolder
		newItemPart:SetNetworkOwner(plr)
	end
end)

Also, there are no errors showing up.
Thanks!

You can use the studio networkOwnerShip highlight feature to check if the client lose ownership . If that is the case, you can figure out what cause it or maybe use a loop that runs every one second to set the network ownership to the client

ye the problem is that I already have it, just above those lines in the local script there’s a while loop that fires an event to the server every 10 secs and that updates their ownership, so I think that’s not the case?

Ok so I tried to change the update delay from 10 seconds down to 1 or 2 seconds, and apparently it worked but idk if that’s the best solution :confused:

1 Like

you should use the remote even to toggle it so that you only need fire the remote event once to connect and disconnect

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.