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

My Data Store script isn't working and there are no errors. Any help?

Asked by 5 years ago

So i'm making a data store for my game but it's not working. Here is my script.

01local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerData")
02local playersleft = 0
03 
04game.Players.PlayerAdded:Connect(function(player)
05    playersleft = playersleft + 1
06    local leaderstats = Instance.new("Folder",player)
07    leaderstats.Name = "leaderstats"
08    local exp = Instance.new("IntValue",leaderstats)
09    exp.Name = "Exp"
10    local maxexp = Instance.new("IntValue",leaderstats)
11    maxexp.Name = "MaxExp"
12    maxexp.Value = 100
13    local level = Instance.new("IntValue",leaderstats)
14    level.Name = "Level"
15    local toonys = Instance.new("IntValue",leaderstats)
View all 49 lines...

1 answer

Log in to vote
0
Answered by 5 years ago

Oh I see what you have done. You have set only one data store for 3 values. This just overwrites the before variables, so in the end, you only save the data: Toonys.

Here is a solution:

01local datastore = game:GetService("DataStoreService")
02local  Exp = datastore:GetDataStore("Exp")
03local  Toony = datastore:GetDataStore("Toony")
04local  Level = datastore:GetDataStore("Level ")
05local playersleft = 0
06 
07 
08game.Players.PlayerAdded:Connect(function(player)
09 
10    playersleft = playersleft + 1
11 
12    local leaderstats = Instance.new("Folder",player)
13 
14    leaderstats.Name = "leaderstats"
15 
View all 93 lines...

Hope this helped!

0
That makes sense! and thanks it worked! ScriptToon 70 — 5y
Ad

Answer this question