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

How do I add value in my wins leaderboard?

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

✓ Accepted answer
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

4 comments

0

were do I put this?

0

Ok I will try it out.

0

I did not work

0

never mind it did

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