hi, im new to scripting so i don’t understand too much what to do when you tell me to change the scripts, so please just change my script because i don’t know how to.
i have a leaderstats Points and Stages, and i want that points stats will save data always and stages no but my data save doesn’t work so what wrong with those scripts?
leaderstats:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Stage = Instance.new("IntValue")
Stage.Name = "Stage"
Stage.Value = 1
Stage.Parent = leaderstats
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Value = 0
Points.Parent = leaderstats
end)
SaveData
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
local plrkey = "id_"..plr.userId
local save1 = plr.leaderstats.Points
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
else
local NumberForSaving = {save1.Value}
ds:GetAsync(plrkey, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds.SetAsync("id_"..plr.userId, {plr.leaderstats.Points.Value})
end)