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

how do i use this for multiple values?

Asked by 9 years ago
01fire = script.Parent.Handle
02turret = script.Parent
03range = turret.range
04wait(1)
05game.Workspace.DescendantAdded:connect(function(des)
06    print'hi'
07repeat wait(1)
08    print'hi2'
09    local mag = (fire.Position - game.Workspace:WaitForChild("red").Position).magnitude
10until mag < range.Value
11print'hi3'
12end)

i have a script where wherever i click, a part gets made there, so if i place a part in range of the turret, the output looks like hi h2 h3

then if i place a part WAY out of range, it prints the same thing, if press stop, and then play again and do this: place a part WAY out of range, it prints: hi hi2 hi2 hi2

and on, and on. and then when i put one in range, it does the same thing.

it's very annoying, and i can't figure out how to get the waitforchild to go to another part named the same.

Answer this question