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

When Player Touches Brick, Gain + 1 Win in Leaderboard, Why It's not working?

Asked by 6 years ago

It Doesn't Work

01local datastore = game:GetService("DataStoreService")
02local ds1 = datastore:GetDataStore("winsSaveSystem")--change all "wins" to what value you want and keep doing it
03local Debounce = tick() -- Assign tick() to the variable
04game.Players.PlayerAdded:connect(function(player)
05 local folder = Instance.new("Folder", player)
06 folder.Name = "leaderstats"
07 local wins = Instance.new("IntValue", folder)
08 wins.Name = "Wins"
09 wins.Value = ds1:GetAsync(player.UserId) or 0
10 ds1:SetAsync(player.UserId, wins.Value)
11 
12workspace.Lobby.DROPDOWN.Winner.Touched:Connected(function()
13    if (tick() - Debounce) >= 5 then -- Make sure 5 seconds have elapsed since last debounce
14        Debounce = tick()
15            wins.Value = wins.Value + 1
View all 29 lines...
0
Might want to capitalize Connect, because the lowercased version is deprecated. meteorcrasher118 35 — 6y
0
It doesn't work because you wrote Connected on line 12. SummerEquinox 643 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
01local datastore = game:GetService("DataStoreService")
02local ds1 = datastore:GetDataStore("winsSaveSystem")
03local Debounce = tick()
04game.Players.PlayerAdded:Connect(function(player)
05 local folder = Instance.new("Folder")
06 folder.Parent = player --second argument of .new() deprecated
07 folder.Name = "leaderstats"
08 local wins = Instance.new("IntValue")
09 wins.Parent = folder
10 wins.Name = "Wins"
11 wins.Value = ds1:GetAsync(player.UserId) or 0
12 ds1:SetAsync(player.UserId, wins.Value)
13 
14workspace.Lobby.DROPDOWN.Winner.Touched:Connect(function() --not Connected
15    if (tick() - Debounce) >= 5 then
View all 31 lines...
0
you shouldnt save your datastore everytime wins changes. you're going to overload the datastore Gey4Jesus69 2705 — 6y
0
Furthermore, you shouldn't set the parent first, it should be the last thing you do in most cases. turtle2004 167 — 6y
Ad

Answer this question