local dataservice = game:GetService("DataStoreService")
local datastore = dataservice:GetDataStore("Main",1)
local main = {
textPro = false,
textYay = true
}
game.Players.PlayerAdded:Connect(function(plr)
local Success, Data = pcall(function()
print("Finding plr data")
return datastore:GetAsync(plr.UserId)
end)
if Success then
if Data then
print("Loading data")
main[plr.UserId] = Data
print("Loaded data for "..plr.Name)
else
print("No data ")
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
print("Plr leaving saving data")
local Success, err = pcall(function()
datastore:SetAsync(plr.UserId, main)
print("Saved data for "..plr.Name)
end)
end)
This code doesn’t execute what it’s supposed to do, when the player joins it only prints “Finding plr data”, this tells me that its fetching the data. I thought it could be that I just have no data to load but it doesn’t print “No Data” so there must be something wrong with my code. Does anyone know how to help me fix this?