Problem with leaderstats

  1. What do you want to achieve? Keep it simple and clear!

I want to give all players that are in the Alive team 1 point

  1. What is the issue? Include screenshots / videos if possible!

It doesn’t give the point and i dont get any error in output.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried lookin in the dev forum but theres only articles of people asking how to make leaderstats.

This is the code located in serverscriptservice as server scripts

local function check()
	for i,v in pairs(plrs:GetChildren()) do
		if v:IsA("Player") and v.Team == "Alive" then
		local leader = v:WaitForChild("leaderstats")
		local surv = leader:WaitForChild("Survivals")
        surv.Value = surv.Value + 1
	end
	end
end

The issue seems to be that you’re comparing the v.Team to a string "Alive", but v.Team is a Team object, not a string. You should compare it to the actual Team object, not a string.

local function check()
    for i, v in pairs(plrs:GetChildren()) do
        if v:IsA("Player") and v.Team == game.Teams.Alive then
            local leader = v:WaitForChild("leaderstats")
            local surv = leader:WaitForChild("Survivals")
            surv.Value = surv.Value + 1
        end
    end
end
1 Like

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