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

What is wrong with this DataStore system script? It does not save the points.

Asked by 6 years ago

These are the script that I have input for my point datastore system, It's like it does not work it only work once but then like when you rejoined the game like 3 times it does not save anymore. Please help.

This is the script.

local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("PointsSaveSystem")

game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Points = Instance.new("IntValue",leader) Points.Name = "Points" Points.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, Points.Value) Points.Changed:connect(function() ds:SetAsync(player.UserId, Points.Value) end) end)

game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Points.Value) end)

0
Use a code block User#20388 0 — 6y
0
Try getting rid of the saving line just before the changed event. I can see this saving their points as zero before the value is updated. Also, make sure you use a code block when you post your scripts. That makes it more easy for us to read. ThatPreston 354 — 6y
0
What is code block? gbtandoc 0 — 6y

Answer this question