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 8 years ago
fire = script.Parent.Handle
turret = script.Parent
range = turret.range
wait(1)
game.Workspace.DescendantAdded:connect(function(des)
    print'hi'
repeat wait(1)
    print'hi2'
    local mag = (fire.Position - game.Workspace:WaitForChild("red").Position).magnitude
until mag < range.Value
print'hi3'
end)

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