how do i make the clone delete after waiting a little
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local ragdollV3 = script.RagdollV3:Clone() ragdollV3.Parent = character ragdollV3.Disabled = false end) end)
You could simply use 2 common built in functions, wait() and :Destroy():
wait() -- Put the amount of time you want the script to wait forin the parenthesis ragdollV3:Destroy() -- :Destroy() completly removes the object from the game
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local ragdollV3 = script.RagdollV3:Clone() ragdollV3.Parent = character ragdollV3.Disabled = false coroutine.wrap(function() wait(time) -- your time ragdollV3:Destroy() end)() -- () is used for calling the coroutine -- coroutines basically run code without stopping the entire thread. it's useful but there's a stack trace issue end) end)
Hello! You can use the Debris
Service!!! Here's how it goes:
Debris has a function called AddItem. The first argument is the object to be removed and the second is the how long does Debris have to wait before removing the object.
Debris:AddItem(<item>, <lifetime>)
When applied to your script:
local Debris = game:GetService("Debris") game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local ragdollV3 = script.RagdollV3:Clone() ragdollV3.Parent = character ragdollV3.Disabled = false Debris:AddItem(ragdollV3, 3) --ragdollV3 will be removed after 3 seconds end) end)
I hope this helps!