#Leaderstats not working

107 messages · Page 1 of 1 (latest)

twin widget
#

leaderstats code

game.Players.PlayerAdded:Connect(function(player)
    
    local leaderstats = Instance.new("folder")
    leaderstats.Parent = player
    leaderstats.Name = "leaderstats"
    
    local stage = Instance.new("IntValue")
    stage.Parent = leaderstats
    stage.Name = "Stage"
    stage.Value = require(game:GetService("ServerScriptService").Stage).stage
    
end)
#

checkpoint code

local Players = game:GetService("Players") -- Player Service
local ServerStorage = game:GetService("ServerStorage") -- Server Storage

local checkpoint = script.Parent -- Getting The Checkpoint

function onTouched(hit)
    if hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid") then -- Getting The Hit.Parent
        local player = Players:GetPlayerFromCharacter(hit.Parent) -- Checking If Player
        local checkpointData = ServerStorage:FindFirstChild("CheckpointData") -- This Line Is Not Necessary 
        if not checkpointData then 
            checkpointData = Instance.new("Folder") -- Creating The Folder For Checkpoint Data
            checkpointData.Name = "CheckpointData"
            checkpointData.Parent = ServerStorage 
        end

        local userIdString = tostring(player.UserId)
        local checkpointValue = checkpointData:FindFirstChild(userIdString) -- Getting The User Id String
        if not checkpointValue then
            checkpointValue = Instance.new("ObjectValue") -- Creating A New User Id String
            checkpointValue.Name = userIdString
            checkpointValue.Parent = checkpointData
            
            player.CharacterAdded:connect(function(character) -- Getting The Player Character
                wait() -- Waiting Until The Play Character Is Added
                local storedCheckpoint = ServerStorage.CheckpointData[userIdString].Value -- Checking To Make Sure It's The Correct Person
                character:MoveTo(storedCheckpoint.Position + Vector3.new(math.random(-4, 4), 4, math.random(-4, 4))) -- If The Character Dies It Will Teleport To Checkpoint
            end)
        end

        checkpointValue.Value = checkpoint -- Making Sure It's The Right Checkpoint
    end
end

checkpoint.Touched:Connect(onTouched) -- Starting The Function When The Checkpoint Is Touched
require(game:GetService("ServerScriptService").Stage).advance(8)
#

module code

local module = {}

module.stage = 1
function module.advance(current_stage)
    if current_stage > module.stage then
        module.stage += 1
    end
end


pallid knot
twin widget
#

what

#

oh ty

#

well it still doesnt work

pallid knot
#

Try setting normal value for stage and check if it works

twin widget
#

i'm pretty new, wdym normal value>

pallid knot
#

Like 1

#

Or 2

#

Not require a module

twin widget
#

didnt work

#

it just doesnt show in the leaderboard

#

can we go priv chat so i could screenshare

pallid knot
#

Maybe don't use ai

pallid knot
#

On explorer

twin widget
#

in serverscriptservice

pallid knot
pallid knot
twin widget
gritty kelp
#

hes been on this since yesterday and legit has no clue what hes doing

twin widget
#

script is leaderstats

twin widget
#

tutorial said it'd do leaderstats

gritty kelp
#

i said not to use modules and to learn scripting first

twin widget
#

i know how to script

gritty kelp
#

Your module code is wrong

twin widget
#

but if i dont use modules how will i do leaderboards

pallid knot
twin widget
gritty kelp
#

learn how to script

twin widget
#

bro where am i wrong in the module script

#
local module = {}

module.stage = 1
function module.advance(current_stage)
    if current_stage > module.stage then
        module.stage += 1
    end
end

return module```
pallid knot
#

That shit won't do anything

twin widget
#

i don't see anything wrong

#

how

#

all i want is a stage leaderstat 😭

pallid knot
#

Return doesn't exists, and global var for all players? Ye no

twin widget
#

wait what

#

doesn't it make the variable for everyone

gritty kelp
#

also not using arguments and paramters

pallid knot
pallid knot
twin widget
#

will turning the module sript into a local one work

gritty kelp
#

No

#

Not at all

twin widget
#

...

#

how can i fix it please

#

i need to learn

gritty kelp
#

‘’’lua

game.Players.PlayerAdded:Connect(function(player)

local leaderstats = Instance.new("folder")
leaderstats.Parent = player
leaderstats.Name = "leaderstats"

local stage = Instance.new("IntValue")
stage.Parent = leaderstats
stage.Name = "Stage"
stage.Value = 0

end)

twin widget
#

`

gritty kelp
#

you are 100% not using output

twin widget
#

is the symbol

twin widget
#

why did u resend my code'

#

?

pallid knot
#

It's not

twin widget
#

it is

#

all he changed is from Folder to folder and from 1 to 0

#

at stage value

pallid knot
#

Exacly

twin widget
#

nvm i had folder too

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

this is legit my code

#

whats wrong with it

#

turning it to 0 doesn't work

#

wow

#

i made a leaderstat actually work

#

now the updating part

pallid knot
twin widget
pallid knot
twin widget
#

ai?

#

i didn't

gritty kelp
twin widget
#

checkpoint someone else gave

#

and then he explained it to me

#

it saves player's position when he touches checkpoint and then if he dies it respawns it to a random position from the checkpoint

#

that's what i learnt from the guy who explained it to me

pallid knot
#

So u still havent made it

twin widget
#

i made some changes to it

#

but still

#

also

#

what's wrong if someone else made me a code and then explained it to me so i can learn it?

#

is it not allowed or something?

young stirrup
gritty kelp
twin widget
#

ye

gritty kelp
#

and is not taking my advice

twin widget
#

ur advice is to not use globals

#

when i need them

#

how else will i store the stage value and modify it?

twin widget
gritty kelp
#

the stage value is stored in the leaderstats folder

twin widget
#

yes, and how will i modify it?

gritty kelp
#

player.leaderstats.Stage.Value += 1

twin widget
#

thanks a lot

#

i'll go try it

#

i never thought of accesing a folder that is made by script

gritty kelp
#

get rid of the module

twin widget
#

okay

#

i've just finished replacing the end function from the checkpoints scripts and it told me something about player

twin widget
#

it doesn't work

#

ok what