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

Points only give to one player??? Any help?

Asked by 9 years ago

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) 
1
Did anything come out on Output? HungryJaffer 1246 — 9y
0
No CarterTheHippo 120 — 9y
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. BSIncorporated 640 — 9y
0
so if i remove the wait it will work correctly CarterTheHippo 120 — 9y
View all comments (3 more)
0
Probably, no guarantee but that is my best guess. I BSIncorporated 640 — 9y
0
It works, thank you! CarterTheHippo 120 — 9y
0
If you want it to wait(7) then move 2 of your ends up to right before the wait(7) BSIncorporated 640 — 9y

Answer this question