My script gives points to the bright red team, however it only gives to one player on that team :(. What did I do wrong?

Here is my script:

game.Workspace.ChildAdded:connect(function(child) 

if child.Name == "HostageFree" then 
script.Sound:Play()

for _,player in pairs(game.Players:GetPlayers()) do  
if player.TeamColor == BrickColor.Red() then 
local leaderstats = player.leaderstats
local points = leaderstats:findFirstChild("Credits") 
points.Value  = points.Value +200

wait(7)
local pl = game.Players:GetChildren()
for i=1,#pl do
pl[i].Character.Humanoid.Health = 0
game.Workspace.HostageFree:Remove()
end
end 
end
end 
end) 

7 comments

1

Did anything come out on Output?

0

No

0

Your issue is as it runs through each child, the wait(7) is delaying the points given, Im pretty sure if you wait they will all be given out.

0

so if i remove the wait it will work correctly

0

Probably, no guarantee but that is my best guess. I

0

It works, thank you!

0

If you want it to wait(7) then move 2 of your ends up to right before the wait(7)