--i wait for the event to fire once. once fired it will not do it again
script.Parent.Touched:Wait()
-- exactly your code
task.wait(2)
local Clone = script.Parent:Clone()
Clone.Parent = game.Workspace
Clone.Anchored = true
Clone.Transparency = 1
Clone.CanCollide = false
task.wait(0.3)
script.Parent.Anchored = false
wait(5)
Clone.Transparency = 0
Clone.CanCollide = true
wait(20)
script.Parent:Destroy()
local debounce = true
script.Parent.Touched:Connect(function()
if debounce == true then -- check if debounce is true
debounce = false -- set the debounce to false
task.wait(2)
local Clone = script.Parent:Clone()
Clone.Parent = game.Workspace
Clone.Anchored = true
Clone.Transparency = 1
Clone.CanCollide = false
task.wait(0.3)
script.Parent.Anchored = false
wait(5)
Clone.Transparency = 0
Clone.CanCollide = true
wait(20)
debounce = true -- set the debounce back to true
script.Parent:Destroy()
end
end)
The Clone() event spawns multiple clones because the part is constantly being touched by another object or a player. Try adding a debounce/cooldown to it.