Alright, so basically I'm making a basic save data thing. it's really simple. When you click a button, it saves that you clicked the button and the button will show as the clicked version of the button next time you boot up the game. The only issue I'm having (I did extensive research on how to fix it, and found nothing) is that I'm only getting the error message in return. This should explain it.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
local Ready = true
game.Players.PlayerAdded:Connect(function(plr)
plr.Archivable = true
local Account = Instance.new("BoolValue")
Account.Parent = plr:FindFirstChild("PlayerGui")
Account.Name = "Account"
print(plr:FindFirstChild("PlayerGui").Account.Value)
local data
local success, errormessage = pcall(function()
data = DataStore:GetAsync("Gamer"..plr.UserId)
end)
if success then
plr.PlayerGui.Account.Value = true
print("okay")
else
plr.PlayerGui.Account.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
DataStore:SetAsync("Gamer"..plr.UserId,plr:FindFirstChild("PlayerGui").Account.Value)
end)
if success then
print("Save Successful")
end
if errormessage then
print("HKFBKWFHBKWHKFBHKWBFWJKFJWKBFKJBWJKFBKJWJKF")
end
end)
Every time I leave the game it prints: "HKFBKWFHBKWHKFBHKWBFWJKFJWKBFKJBWJKFBKJWJKF"
Please help

1 comment
did you test it in studio?