How to measure Team leaderstats

it didnt work but this is my serverscript

--On a server script
local remoteEvent=game.ReplicatedStorage.W--Get the adress of your remote event here, it allows communication between server and client

local function decideWinner()
	local northTeamPoints=0
	local southTeamPoints=0
	local Winner

	for _,player in pairs(game.Players:GetPlayers()) do
		if player.Team==game.Teams.North then
			northTeamPoints += player.leaderstats.Value.Value
		elseif player.Team==game.Teams.South then
			southTeamPoints +=player.leaderstats.Value.Value
		end
	end

	if northTeamPoints>southTeamPoints then
		remoteEvent:FireAllClients(game.Teams.North)
	elseif southTeamPoints>northTeamPoints then
		remoteEvent:FireAllClients(game.Teams.South)
	elseif southTeamPoints==northTeamPoints then
		remoteEvent:FireAllClients(nil)
	end

end

while wait(3) do
	if game.StarterGui.TopText.Time.Text == "Deciding Winner..." then
		decideWinner()
	end
end


2 Likes

And where is the text set from anyways?

Instead of a string you should check a value or just do the logic in the while loop

local IntermissionTimer=15 --You can hard code this
local gameTimer=600

while true do --Infinite loop, never ends
--Intermission logic here
wait(intermissionTimer)
--Game starts
wait(gameTimer)
--Game Ends 
decideWinner()
end

I’m on mobile so can’t type correctly the code here

2 Likes

its not changing the value fr some reasonj wnnjdaj

2 Likes

type here the clientside script

1 Like

You’re setting the values from the server right? Because I’m starting to feel you may accidentally be doing it from the client

2 Likes

the script is in serverscriptservice

2 Likes

I mean the value from the player’s leaderstats, i know you get the final score on the server

2 Likes

I mean you can do something like this:

if teamBlue.Score > teamRed.Score then
 --  display it
elseif teamBlue.Score < teamRed.Score then
 --  display it
elseif teamBlue.Score == teamRed.Score then
 --  display it
end

it would be something like that?

3 Likes

im trying to get the score for each team rn

1 Like

well yeah you display the scores.

1 Like

Show the piece of code that adds the points to an individual player, when does the player get points and where os the script that does it

1 Like

well you will be able to display like this then.

textlabel.Text = teamBlue.Score

You can use attributes for this or values how ever you like.

like how players get points?uyjhrtgrfewewffew

1 Like

Exactly, where is the lines that add onto the player’s point

1 Like

ive been just changing the value in my leaderstats folder for testing

1 Like

When you edit the value is you’re testing mode on client or server?

1 Like

how do i tell?mdjfewnjnfwenewfuwefuuwef

1 Like

In the testing menu of studio you can see and toggle between them

It says local server in the testing tabmsanjkasja

2 Likes

When you are testing, already pressed the play button there is a button to switch between them, a local server is just a Roblox server but in your computer to test with multiple players

2 Likes