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

How to add cash to all members of a team?

Asked by
saucyP 7
8 years ago

I'm using the default Roblox CTF script (which could be found in the CTF Template), and I made an IntValue in leaderstats called Cash. I found out how to add cash to the player who succesfully captured the flag, but I want to be able to add cash to all the players of the team who scored a point. The part where the script adds the point is on lines 116 - 120. Here's the script:

001local TeamManager = {}
002 
003-- ROBLOX services
004local Teams = game.Teams
005local Players = game.Players
006 
007-- Game services
008local Configurations = require(game.ServerStorage.Configurations)
009local DisplayManager = require(script.Parent.DisplayManager)
010 
011-- Local variables
012 
013local TeamPlayers = {}
014local TeamScores = {}
015 
View all 122 lines...

If you are on the template, you can find this script in: game.ServerScriptService.MainGameScript.GameManager.TeamManager

2 answers

Log in to vote
0
Answered by 8 years ago
1for i,v in pairs(game.Players:GetPlayers()) do
2    if v.TeamColor == BrickColor.new("Really Red") then --change really red to brickColor of team
3        v.leaderstats.Cash = v.leaderstats.Cash + 100 --amount to give
4    end
5end
0
But how will I make it when Blue captures, everyone in blue gets +100, and when Red captures, everyone in red gets +100 saucyP 7 — 8y
0
You could change the brick color that it checks to a variable that you give when you call your AddTeamScore function. Troidit 253 — 8y
Ad
Log in to vote
0
Answered by
saucyP 7
8 years ago

Nevermind, I fixed the script based off the first answer. Here's what I put:

1function TeamManager:AddTeamScore(teamColor, score)
2    local team = GetTeamFromColor(teamColor)
3    TeamScores[team] = TeamScores[team] + score
4    DisplayManager:UpdateScore(team, TeamScores[team])
5    for i,v in pairs(game.Players:GetPlayers()) do
6    if v.TeamColor == teamColor then --change really red to brickColor of team
7        v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 100 --amount to give
8    end
9end

Answer this question