local Teams = game:GetService("Teams")
local rs = game.ReplicatedStorage
local red = rs.teamre:WaitForChild("red")
local blue = rs.teamre:WaitForChild("blue")
local green = rs.teamre:WaitForChild("green")
local yellow = rs.teamre:WaitForChild("yellow")
local Amount = 1
-- Function to add +1 to the leaderstat of players on the yellow team
local function updatered(Red,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == Red then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
end
local function updateblue(Blue,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == Blue then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
end
local function updategreen(Green,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == Green then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
end
local function updateyellow(Yellow,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == Yellow then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
end
red.OnServerEvent:Connect(updatered)
blue.OnServerEvent:Connect(updateblue)
green.OnServerEvent:Connect(updategreen)
yellow.OnServerEvent:Connect(updateyellow)```
The remote event triggers, the leaderstat isn't changing, any help?
local function updatered(Red,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == Red then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
en
the color name and “Amount” variables defined in these functions have no values
so when you compare the team name to the color name, it is always false
quotes around something makes it a string or a word
when theres no quotes its a variable and doesnt have to be a string
it doesnt work because the team name is a string (or word), and the variable “Red” has no value
change each one to this format where the color name is in quotes:
local function updatered(Red,Amount)
for _,player in pairs(game.Players:GetChildren()) do
if player.Team.Name == "Red" then
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
end
end
en