Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderstats not being added?

Asked by 7 years ago

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

Log in to vote
0
Answered by
Xeo_n 0
7 years ago

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,

0
leaderstats need to be an Intvalue for it to show up. thesit123 509 — 7y
0
oh ok Xeo_n 0 — 7y
Ad

Answer this question