Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make a script repeat itself? [closed]

Asked by
AspectW 431 Moderation Voter
8 years ago
Edited 8 years ago

How can I make

1local SCP049=script.Parent;
2local clone = SCP049:Clone()
3SCP049.Humanoid.Died:connect(function()
4wait(5)
5SCP049:Destroy()
6clone.Parent = Workspace
7end)

repeat when its done without making roblox crash?

1
WOOOOO!!! QUESTION 40.000! RubenKan 3615 — 8y

Locked by youtubemasterWOW

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

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:

01local SCP049 = script.Parent;
02local clone = SCP049:Clone()
03 
04function respawn()
05    wait(5)
06    SCP049:Destroy()
07    SCP049 = clone:Clone()
08    SCP049.Parent = workspace
09 
10    SCP049.Humanoid.Died:connect(respawn)
11end
12 
13SCP049.Humanoid.Died:connect(respawn)
Ad
Log in to vote
-1
Answered by 8 years ago

Simple, use a

1while true do
2 
3end

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

1while true do
2wait(1)
3 
4end

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 : )