My script here resets the players/game, but don't worry about that. Before all of that happens I need the bright red team to be given credits, but I am not sure how...
Here is my script
game.Workspace.ChildAdded:connect(function(child) if child.Name == "HostageFree" then wait(0.05) --here is were they need to be given credits (200 of them) wait(10) local pl = game.Players:GetChildren() for i=1,#pl do pl[i].Character.Humanoid.Health = 0 game.Workspace.HostageFree:Remove() end end end)
That is very simple. You just need a for
in pairs
to detect people on Bright Red and give them their bounty. I also combined the below for
loop inside the new one.
game.Workspace.ChildAdded:connect(function(child) if child.Name == "HostageFree" then --Wait is unneccesary for _,player in pairs(game.Players:GetPlayers()) do if player.TeamColor == BrickColor.Red() then player.leaderstats.Credits = player.leaderstats.Credits + 200 end player.Character.Humanoid.Health = 0 --You can also use player:LoadCharacter() instead to respawn them swiftly, but i'll leave you to choose instead. end wait(10) game.Workspace.HostageFree:Destroy() --Remove() is deprecated, use Destroy() where possible instead end)