So I made like a bomb that after some events the bomb get destroyed but when it happens the game has lag spikes here is the script
local bomb = script.Parent
local fire = script.Parent.BombComponets.Emitter1:WaitForChild("FireEffect")
local bombpart script.Parent.BombComponets:WaitForChild("BombPart")
local emitter1 = script.Parent.BombComponets:WaitForChild("Emitter1")
local emitter2 = script.Parent.BombComponets:WaitForChild("Emitter2")
local emitter3 = script.Parent.BombComponets:WaitForChild("Emitter3")
if bomb.Parent == workspace then
wait(5)
fire.Parent = emitter2
wait(5)
fire.Parent = emitter3
wait(1)
fire:Destroy()
local explosion = Instance.new("Explosion")
explosion.Parent = workspace
explosion.Position = bomb.BombComponets:WaitForChild("BombPart").Position
bomb:Remove()
end
I changed the destroy to :remove thinking It whould stop the lag spikes but both give the same result
I took a bomb tool out of the tool box to see if the lag was from my script or for roblox studio itself
when the bomb that the tool dropped got destroyed the same lag spikes appeared but when I drop another bomb and got destroyed magicaly there was no lag spikes anymore so is the first time that get destroyed that the lag spikes comes in place
It’s most likely that it is since this happens with everything, it has to do with how the destruction of things is handled in Roblox Studio and I don’t know if maybe something with the garbage collector too and it also depends on the PC because it didn’t happen to me on my main PC
I tested it, It’s because your destroying the scripts parent and it destroys the script causing the lag. so make the script not a child of the part and it should not lag.
not to be rude or anything but your PC might just suck. the game shouldn’t lag under a simple :Remove() operation which is just parenting the object and its children to nil.