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
Did anything come out on Output?
No
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.
so if i remove the wait it will work correctly
Probably, no guarantee but that is my best guess. I
It works, thank you!
If you want it to wait(7) then move 2 of your ends up to right before the wait(7)