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

How do I make a +1 tool that ups a leaderstat by 1?

Asked by 6 years ago

Okay so if you go intro a simulator game and they have a tool that gives u a +1 on a leaderstat.

I would like to know how this is made If you need here is my leaderstat script & my save data script

[Leaderstat]

game.Players.PlayerAdded:connect(function(player)
    local Leaderstats = Instance.new("Folder")
    Leaderstats.Name = "leaderstats"
    Leaderstats.Parent = player

    local Level = Instance.new("IntValue")
    Level.Name = "Level"
    Level.Value = 1
    Level.Parent = Leaderstats
end)

[Datasave]

function onPlayerEntered(player)
wait()
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end

function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

0
MouseClick HelperScripting -4 — 6y

Answer this question