How do I change everyone on a team's leaderstats?

local Players = game:GetService("Players")
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.leaderstasts.Wins.Value += Amount
		end
	end

end

local function updateblue(Blue,Amount)
	for _,player in pairs(game.Players:GetChildren()) do
		if player.Team.Name == Blue then
			player.leaderstasts.Wins.Value += Amount
		end
	end

end

local function updategreen(Green,Amount)
	for _,player in pairs(game.Players:GetChildren()) do
		if player.Team.Name == Green then
			player.leaderstasts.Wins.Value += Amount
		end
	end

end

local function updateyellow(Yellow,Amount)
	for _,player in pairs(game.Players:GetChildren()) do
		if player.Team.Name == Yellow then
			player.leaderstasts.Wins.Value += Amount
		end
	end

end

red.OnServerEvent:Connect(updatered)
blue.OnServerEvent:Connect(updateblue)
green.OnServerEvent:Connect(updategreen)
yellow.OnServerEvent:Connect(updateyellow)

For some reason it isn’t updating the wins leaderstat, does anyone know why?

1 Like

There’s a typo in these lines.

You spelled leaderstats wrong.

It should be:
player.leaderstats.Wins.Value += Amount
instead of
player.leaderstasts.Wins.Value

1 Like

Didn’t even see that, thanks you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.