I’m making a Tycoon game and I have this problem right now.
Whenever I lagged and then goes back to normal the Dropper suddenly dropped a lot of Parts. I suspected this come from the Parts that are not spawned due to the lag.
I tried to search on the DevForum but I don’t find anything that can help me.
while task.wait() do
if tick() - spawneggcooldown >= Settings.SpawnTime then
spawneggcooldown = tick()+69e100
task.spawn(function()
for _,egg in pairs(PlayerData.Eggs:GetChildren()) do
if discontinue then break end
local data = Eggs[egg.Name]
local obj: Part = data.Egg:Clone()
local worth = Instance.new('NumberValue',obj)
worth.Value = data.Worth.Value
worth.Name = 'Worth'
local tag = Settings.EggTag:Clone()
tag.Adornee = obj
tag.Parent = obj
obj.Name = egg.Name
tag.Worth.Text = '$'..AddComma.Format(data.Worth.Value)
obj.Parent = Plot.Eggs
obj.CFrame = Plot.EggStart.CFrame
obj:SetNetworkOwner(player)
task.wait(Settings.SpawnDelay)
end
spawneggcooldown = tick()
end)
end
end
Is there anything I can do to prevent this from happening?