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

Can anyone help? Datastore script seems to add a level every time the player leaves and rejoins.

Asked by 5 years ago
Edited 5 years ago

Yo, so my datastore script seems to have this issue where instead of saving the players level and exp, it for some reason jumps a level or two sometimes?? (for example: the players level would be 1, then once they leave and rejoin it becomes 2?)

Here is the code if anyone wants to know;

01local DSService = game:GetService("DataStoreService"):GetDataStore("-test#1222")
02local RunService = game:GetService("RunService")
03 
04game.Players.PlayerAdded:Connect(function(plr)
05    local uniquekey = 'id-'..plr.userId
06    local leaderstats = Instance.new("Folder", plr)
07    local Level = Instance.new("NumberValue")
08    local EXP = Instance.new("NumberValue")
09    local MaxEXP = Instance.new("NumberValue")
10    local Cash = Instance.new("NumberValue")
11    local FactionEXP = Instance.new("NumberValue")
12 
13        local Strength = Instance.new("NumberValue")
14        local Stamina = Instance.new("NumberValue")
15        local Defence = Instance.new("NumberValue")
View all 97 lines...
0
Contact me via discord and I might be able to help you in another way Mystifine#4924 BlackOrange3343 2676 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Heres my datastore:

01local Ds = game:GetService("DataStoreService") -- access datastore
02local abilites = Ds:GetDataStore("PlayerStats_00") -- Datastore key
03 
04function getPlayerData(player) -- load data
05    local success, data = false, nil
06    repeat
07        success = pcall(function()
08            data = abilites:GetAsync(player.UserId)
09        end)
10    until success
11 
12    player.IfData.Value = true
13 
14    return data
15end
View all 60 lines...
0
that didnt seem to fix the problem? any other ideas? Busoshoaku 0 — 5y
0
Maybe I could show you my datastore its kind of similar XxWingKing 96 — 5y
0
alright, that would be really helpful since i could just edit the values Busoshoaku 0 — 5y
0
I have edited my answer XxWingKing 96 — 5y
View all comments (3 more)
0
thanks, im trying it now Busoshoaku 0 — 5y
0
thank you so much! it seems to work fine, if i could upvote you i would because you've spent alot of time trying to help me make this, so thanks alot. Busoshoaku 0 — 5y
0
Could you mark me as the answer XxWingKing 96 — 5y
Ad

Answer this question