So im new to data storing on roblox from tutorials this is what I have come up with I use prints to figure out everything runs fine just on the player removing function when its supposed to save the data it always returns nil and dosent save ive tried over and over can someone explain to me what im doing wrong?
ive tried changing multiple things for about two days now I just want to figure this out.
game.Players.PlayerRemoving:connect(function(plyr)
succsess, err = pcall(function()
if succsess then
local ttt = plyr.PlayerGui:findFirstChild("SavedSpot")
savespot:SetAsync(plyr.UserId.."-SaveNumber",ttt.Value)
print("Saved")
else
warn(err)
print("No Save")
end
playersleft = playersleft - 1
be:Fire()
end)
end)
the player enters the game the data tries to load if the player has never played the data returns nil and makes the value 1 I have separate code in a block when you touch it to set the value to two when the person leaves e.g. the player removing function I want it to save the value two and then load it when the player enters again my only error message I receive is nil