#Leaderboard value won't go up

8 messages · Page 1 of 1 (latest)

mild nacelle
#

set Stage's value when you add it to them in playeradded

#

yes

#

what

#

the error is cuz its trying to compare a number with nil

#

the reason its nil is cuz you dont give it a value before then

#

yh

#

idk man im tired

mild nacelle
#
local Players = game:GetService("Players")

local CheckpointsFolder = game.Workspace.Checkpoints

Players.PlayerAdded:Connect(function(player)
    
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    
    local Stage = Instance.new("IntValue")
    Stage.Name = ("Stage")
    Stage.Value = 1
    Stage.Parent = leaderstats
    
end)

for _, v in pairs(CheckpointsFolder:GetChildren()) do
    
    if v:isA("BasePart") then
        v.Touched:Connect(function(part)
            
            local player = Players:GetPlayerFromCharacter(part.Parent)
            local stageValue = player.leaderstats.Stage
            
            if player and stageValue.Value < tonumber(v.Name) then
                
                stageValue.Value = v.Name
                
                
            end            
        end)
    end
end