Yo
Gonna make this nice and simple, I write this script:
local DataStoreService = game:GetService("DataStoreService")
local TokenStore = DataStoreService:GetDataStore("TokenStore")
game.Players.PlayerAdded:Connect(function(plyr)
local leaderstats = Instance.new("Folder")
leaderstats.Parent = plyr
leaderstats.Name = "leaderstats"
local tokens = Instance.new("IntValue")
tokens.Parent = leaderstats
tokens.Name = "Tokens"
local inGame = Instance.new("BoolValue")
inGame.Name = "inGame"
inGame.Parent = plyr
local isVIP = Instance.new("BoolValue")
isVIP.Name = "isVIP"
isVIP.Parent = plyr
isVIP.Value = true
local tokenData
local success, errormessage = pcall(function()
tokenData = TokenStore:GetAsync(plyr.UserId.."-tokens")
end)
if success then
tokens.Value = tokenData
else
print("There was an error when getting this users data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(plyr)
local success, errormessage = pcall(function()
TokenStore:SetAsync(plyr.UserID.."-tokens",plyr.leaderstats.Tokens.Value)
end)
if success then
print("Player data saved")
else
print("Player data FAILED to save")
warn(errormessage)
end
end)
and it works fine in studio. Sure, the DataStores don’t work, but it’s a DataStore in studio, but when I run it in game, I don’t even get any leaderstats whatsoever
Here’s the in-game errormessages.
Do note that the other two error messages are dependent on the leaderstats to actually function lol