Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Leaderstats not being added?

I may sound like an idiot but i made a button and when you click its supposed to give you leaderstats but its not.

function onClicked(playerWhoClicked)
plr.leaderstats.Clicks.Value = plr.leaderstats.Clicks.Value + 1000
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Add a script into serverscriptservice and put this.

game.Players.PlayerAdded:connect(function(plr) -- when the player joins the game
    local leaderstats=Instance.new("Configuration") --make folder of leaderstats
    leaderstats.Name="leaderstats" --define the name
    leaderstats.Parent=plr -- sets the leaderstats in the player 
    local clicks=Instance.new("NumberValue") --makes the score value
    clicks.Name="Clicks" -- the name
    clicks.Parent=leaderstats --sets it so you can see the score on the leaderboard
end)

then in the part that you click add this.

function onClicked(playerWhoClicked)
        local Player=game.Players:GetPlayerFromCharacter(hit.Parent) -- find the player (using the character)
        Player.leaderstats.Clicks.Value = Player.leaderstats.Clicks.Value + 1 -- adds point
    end
end)
script.Parent.ClickDetector.MouseClick:connect(onClicked)

That might work,

2 comments

0

leaderstats need to be an Intvalue for it to show up.

0

oh ok

This discussion is preserved as it was. New answers, comments, and votes are closed.