Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make a script repeat itself?

How can I make

local SCP049=script.Parent;
local clone = SCP049:Clone()
SCP049.Humanoid.Died:connect(function()
wait(5)
SCP049:Destroy()
clone.Parent = Workspace
end)

repeat when its done without making roblox crash?

1 comment

1

WOOOOO!!! QUESTION 40.000!

2 answers

✓ Accepted answer

When the initial Humanoid dies -that's it. The event never fires again. You have to attach a new function to the new humanoid.

However, you can't make infinitely complex code, so you can't use an anonymous function here:

local SCP049 = script.Parent;
local clone = SCP049:Clone()

function respawn()
	wait(5)
	SCP049:Destroy()
	SCP049 = clone:Clone()
	SCP049.Parent = workspace

	SCP049.Humanoid.Died:connect(respawn)
end

SCP049.Humanoid.Died:connect(respawn)

Simple, use a

while true do 

end

Just put that script in there and put a wait somewhere in there like this

while true do 
wait(1)

end

so it doesn't keep repeating every like 0.1 of a second. It would lag out and crash your server!

If you have any questions feel free to ask : )

This discussion is preserved as it was. New answers, comments, and votes are closed.