I am making a survival type game and at the end of the game there is an asteroid that hits the map and it is supposed to despawn after a certain amount of time it works fine the first time but the second time it hits the map the parent of the asteroid is supposed to change from workspace to server storage but it does not change the second time here are my scripts.
local Asteroid = game.ServerStorage.Asteroid
local p1 = script.Parent.p1
Asteroid.Parent = script.Parent
Asteroid.Position = Vector3.new(713, 1234.5, -82)
Asteroid.Anchored = false
This script spawns in the asteroid
local part = script.Parent
local Ex = Instance.new("Explosion")
script.Parent.Touched:Connect(function()
part.Anchored = false
Ex.BlastRadius = 100000000000
Ex.BlastPressure = 1000000000
Ex.Parent = game.Workspace.Explosions
Ex.Position = Vector3.new(700.5, 1.5, -68)
wait(2)
Ex:Destroy()
part.CanTouch = false
wait(7)
part.Anchored = true
wait(13)
part.Parent = game.ServerStorage
end)
This script explodes and despawns the asteroid but after it runs twice it stops working and does not despawn the asteroid, Thanks.
Well first of all, you don’t actually clone the asteroid in the first place. You just get the asteroid part in ServerStorage and set it’s parent to the script.
Second of all, you’re only deleting the explosion on touch. Not the actual asteroid.