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

My DataStore script isn't saving, there's no errors in the output? [SOLVED]

Asked by 5 years ago
Edited 5 years ago

This is a Script in ServerScriptService, there are no errors, it just doesn't save.

local DSService  = game:GetService("DataStoreService"):GetDataStore('asdpie')
game.Players.PlayerAdded:Connect(function(plr)
    local stuff = Instance.new("Folder")
stuff.Name = ("sub") 
stuff.Parent = plr

 local Strength =  Instance.new("IntValue")
 Strength.Name = 'Strength'
 Strength.Parent = stuff

local SXP = Instance.new("IntValue")

 SXP.Name = 'SXP'
 SXP.Parent = stuff 
-----------------------SAVE DATA-----------------------
local uniquekey = 'id-'..plr.UserId

local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
    Strength.Value = GetSaved[1]

else
    local NumbersForSaving = {Strength.Value}
    DSService:SetAsync(uniquekey,NumbersForSaving)
end
-------------------------------------------------------

SXP.Changed:Connect(function()
    local SXPval = SXP.Value
    if SXP.Value >= Strength.Value * 100 then 
        SXP.Value = SXP.Value - Strength.Value * 100
        Strength.Value = Strength.Value + 1
        end
end)
--[[
Strength.Changed:Connect(function()
        local uniquekey = 'id'..plr.userId
    local Savevtable = {plr.sub.Strength.Value}
    DSService:SetAsync(uniquekey,Savevtable)
end)
]]
end)


game.Players.PlayerRemoving:Connect(function(plr)
    local uniquekey = 'id'..plr.userId
    local Savevtable = {plr.sub.Strength.Value}
    DSService:SetAsync(uniquekey,Savevtable)
end)

0
Try putting print statements to see what gets ran, and when. dude10000009 0 — 5y
0
okay, i'll try that Jacobingg 2 — 5y
0
I got it to work, I made a really stupid mistake, Thanks for the help Jacobingg 2 — 5y
0
Yes, before coming here please remember to try debugging it yourself. 1, it makes you realize your mistakes faster and 2, it helps you to improve on those mistakes. Good job figuring it out though. Stephenthefox 94 — 5y
0
put [SOLVED] in title if you already fixed problem. yHasteeD 1819 — 5y

Answer this question