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

Recognize an new object in workspace. Any help?

Asked by 8 years ago

In my script it can recognize if there are no players on a certain team. I want this script to be able to recognize if a new model enters the Workspace named "HostageFree"

This is my script:

local BluePlayers=0

function GetAmountOnBlue()
BluePlayers=0
local Players=game.Players:GetChildren()
for _,Player in pairs(Players) do
if Player.TeamColor==BrickColor.new("Bright blue") then
BluePlayers=BluePlayers+1
end
end
end

while script.Parent do
wait()
GetAmountOnBlue()
if BluePlayers==0 then
script.Parent.Transparency=1
script.Parent.CanCollide=false
script.Parent.ScaryScript.Disabled = true
else
    script.Parent.ScaryScript.Disabled = false
script.Parent.Transparency=0
script.Parent.CanCollide=true
end
end

Once the script recognizes a new model in workspace it needs to be able to do something like my script does above. Like: kill all players on bright red team but just before that giving everyone on bright red team 300 credits (actually need that).

1 answer

Log in to vote
0
Answered by 8 years ago
game.Workspace.ChildAdded:connect(function(child)
if child.Name == "HostageFree" then
-- do stuff
end
end)
0
will this work and check continously until the model appears in workspace? CarterTheHippo 120 — 8y
0
did not work my friend CarterTheHippo 120 — 8y
Ad

Answer this question