i am working on a system that saves player data when a player leaves or joins, but it doesn't seems to be working, but I not getting any errors and it says its saving properly, how do I fix it?
local DataStoreService = game:GetService("DataStoreService")
local Stage = DataStoreService:GetDataStore("Stage")
local player
local playerid
local usertable
game.Players.PlayerAdded:Connect(function(plr)
player = plr.Name
playerid = plr.UserId
usertable = 'player_' .. playerid
local success , currentlevel = pcall(function()
return Stage:GetAsync(usertable)
end)
if success then
game.ReplicatedFirst.Level.Value = Stage
print('data loaded:' .. game.ReplicatedFirst.Level.Value)
else
print('ok that dident work')
end
end)
game.Players.PlayerRemoving:Connect(function()
local success , Stage = pcall(function()
Stage:SetAsync(usertable,game.ReplicatedFirst.Level.Value)
end)
if success then
print('data saved: ' .. game.ReplicatedFirst.Level.Value)
end
end)

1 comment
local breathingName = "HaveBreathing" local birdName = "HaveBird" local DataStore = game:GetService("DataStoreService"):GetDataStore("TestDataStore") game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder") folder.Name = "bool" folder.Parent = player local havebird = Instance.new("IntValue") havebird.Name = birdName havebird.Parent = folder local havebrea