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

Give Bright red Team Credits. Any help?

Asked by 8 years ago

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) 

1 answer

Log in to vote
1
Answered by
Marios2 360 Moderation Voter
8 years ago

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)
0
killing them changes there team color and removes the weapons they have CarterTheHippo 120 — 8y
0
the leader stat is under points but the name on leaderboard is Credits, will that effect this script? CarterTheHippo 120 — 8y
0
Helloooo? CarterTheHippo 120 — 8y
Ad

Answer this question