Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Recognize an new object in workspace. Any help?

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

✓ Accepted answer
game.Workspace.ChildAdded:connect(function(child)
if child.Name == "HostageFree" then
-- do stuff
end
end)

2 comments

0

will this work and check continously until the model appears in workspace?

0

did not work my friend

This discussion is preserved as it was. New answers, comments, and votes are closed.