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)

5 comments

0

Try putting print statements to see what gets ran, and when.

0

okay, i'll try that

0

I got it to work, I made a really stupid mistake, Thanks for the help

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.

0

put [SOLVED] in title if you already fixed problem.