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

How would I make this work more then once?

Asked by 10 years ago

This only works once, and will not work again

local map = game.Workspace:WaitForChild("o1") 
if map then
    print("Coming Soon!")
end

What it does is when an object named o1 is put in Workspace, it prints " Coming Soon "

How would I make this able to be used unlimited times, not just one?

0
Why downvote? Its not a bad question... I tried to make it loop and failed... ggggyourface23 63 — 10y

2 answers

Log in to vote
0
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

Do you mean that you want to print out a message whenever an instance with a particular name is added to the Workspace? If so, you should be using the ChildAdded event. The problem with using WaitForChild in this case is that it only wants to find the first child with a particular name, and once the child is added, it's done.

game.Workspace.ChildAdded:connect(function(child)
   if child.Name == "o1" then
      print("Coming soon")
   end
end)
Ad
Log in to vote
0
Answered by 10 years ago

Do you want it constant? Because this would work infinitely.

local map = game.Workspace:WaitForChild("o1")

while map do
    print("Coming Soon!")
    wait()
end
0
No. When I use the above, I put o1 in workspace as a test, then it works. Then I put it out and back in workspace, and nothing happens ggggyourface23 63 — 10y

Answer this question