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

Why Leaderboard Score Won't Go More Than 40?

Asked by 5 years ago

I Have 40 wins, I Win Again but It Won't Say Up There 41 wins, Stuck To 40 won't go upper

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("winsSaveSystem")--change all "wins" to what value you want and keep doing it 
local Debounce = tick() -- Assign tick() to the variable
game.Players.PlayerAdded:Connect(function(player)
 local folder = Instance.new("Folder", player)
 folder.Name = "leaderstats"
 local wins = Instance.new("IntValue", folder)
 wins.Name = "Wins"
 wins.Value = ds1:GetAsync(player.UserId) or 0
 ds1:SetAsync(player.UserId, wins.Value)

workspace.Lobby.DROPDOWN.Winner.Touched:Connect(function()
    if (tick() - Debounce) >= 5 then -- Make sure 5 seconds have elapsed since last debounce
        Debounce = tick()
            wins.Value = wins.Value + 1


    end
end)



 wins.Changed:Connect(function()
  ds1:SetAsync(player.UserId, wins.Value)
 end)



end)

0
Anything in the output? Stephenthefox 94 — 5y
0
Never save anything on a Changed event. Also, when you save, wrap the SetAsync/UpdateAsync in a pcall. User#25115 0 — 5y
0
Nothing on Output, By the way how do i wrap SetAsync/UpdateAsync BloxEnergy -76 — 5y
0
An example of pcall being used would be pcall(ds1.SetAsync, ds1, player.UserId, wins.Value). User#25115 0 — 5y
View all comments (2 more)
0
pcall has two return values, the first one being a boolean that says whether or not a save was successful, and the second one is an error message if the save was unsuccessful. The error message would be nil if the save was a success. User#25115 0 — 5y
0
You can set two variables to those return values like so: local success, message = pcall(ds1.SetAsync, ds1, player.UserId, wins.Value). User#25115 0 — 5y

Answer this question