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

How do I add value in my wins leaderboard?

Asked by 4 years ago
Edited 4 years ago

Techno0ne posted this one to but it still did not work for me can someone please help? This is the win giver script.

amnt = 1 --how much you get for it

return function(winner)
    function onTouched(part)
        local h = part.Parent:findFirstChild("Humanoid")
        if (h~=nil) then
            local thisplr = game.Players:findFirstChild(h.Parent.Name)
        if (thisplr~=nil) then
            local stats = thisplr:findFirstChild("leaderstats")
        if (stats~=nil) then
            local score = stats:findFirstChild("Wins")
        if (score~=nil) then
            score.Value = score.Value + amnt
                end
            end
        end
    end
end

end

This is the leader board.

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("WinsSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstats"
 local wins = Instance.new("IntValue", folder)
 wins.Name = "Wins"

 wins.Value = ds1:GetAsync(plr.UserId) or 0
 ds1:SetAsync(plr.UserId, wins.Value)

 wins.Changed:connect(function()
  ds1:SetAsync(plr.UserId, wins.Value)
 end)
 end)


If anyone knows please help! Look at the game if you want to see what I'm talking about. https://web.roblox.com/games/5270154521/ALTERCATION-ALPHA?refPageId=098a8aa0-0382-4f17-b668-a9edbd92c5af

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
amnt = 1 --how much you get for it

return function(winner)
    function onTouched(part)
        local h = part.Parent:findFirstChild("Humanoid")
        if (h~=nil) then
            local thisplr = game.Players:findFirstChild(h.Parent.Name)
        if (thisplr~=nil) then
            local stats = thisplr:findFirstChild("leaderstats")
        if (stats~=nil) then
            local score = stats:findFirstChild("Wins")
        if (score~=nil) then
game.Players.LocalPlayer.leaderstats.Wins =game.Players.LocalPlayer.leaderstats.Wins + amnt
                end
            end
        end
    end
end

end
0
were do I put this? cocajola3 6 — 4y
0
Ok I will try it out. cocajola3 6 — 4y
0
I did not work cocajola3 6 — 4y
0
never mind it did cocajola3 6 — 4y
Ad

Answer this question