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!