How would I make a part respawn automatically after exploding?

Im making a stage in an obby where a sphere is placed in the arena, and will explode after 5 seconds. How would i make it respawn at its original spot?

Is it just a part set as a ball with a couple properties changed? If so you can just create a new object using Instance.new() and put it in the position of the previous one along with its previous properties.

local new_sphere = Instance.new("Part")
new_sphere.Shape = Enum.PartType.Ball
new_sphere.CFrame = CFrame.new() -- whatever position
-- any other properties you need to change
new_sphere.Parent = workspace
1 Like

No, the part has a kill script inside of it, So i need to be able to clone it.

Put the part in some storage place like ServerStorage or ReplicatedStorage, then repeatedly clone it from there and set the position to wherever you need to.

local ball = game:GetService("ServerStorage"):FindFirstChild("ExplodingBall")
function cloneBall()
     local ballClone = ball:Clone()
     ballClone:PivotTo() -- position
     ballClone.Parent = workspace
     ballClone.Destroying:Once(cloneBall)
end

cloneBall()

Edit: Changed :Connect() to :Once(), as it’s a one-time event. Maybe better for memory? idk

2 Likes

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