so i made a table datastore that if you touch a certain part it will put ur userid in the table and when u rejoin u will have "0" level and i tried everything and still does not work i tired reasearching and debugging myself but no changes anyways here is the code:
local ds = game:GetService("DataStoreService"):GetDataStore("IdkData")
local save = {}
game.Workspace.Crown.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local Mainplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
table.insert(save, Mainplayer.UserId)
print("userid saved!")
end
end)
game.Players.PlayerAdded:Connect(function(player)
local stats = ds:GetAsync(player.UserId.."Crown")
print("hm")
for i, v in pairs(save) do
print("Bruh")
if player.UserId == v then
print("giving coins no werk")
player.leaderstats.Level.Value = 0
end
end
end)
function saveData(player)
local sucess, errorMessage = pcall(function()
ds:SetAsync(player.UserId.."Crown", save)
end)
if sucess then
print("Player Named "..player.Name.." Crown Has Been Saved!")
else
warn("Player Named ".. player.Name.." Had A Data Error!")
end
end
game.Players.PlayerRemoving:Connect(function(player)
saveData(player)
end)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
saveData(player)
end
end)
Thanks!

3 comments
You may need to study how tables work more closely - you currently have a single table
savethat you saving - but all players get this same information saved. Instead, store information per player, typically withsave[player] = dataordata = save[player](that's how you use the table - you also still need to load/save that information from/to the data stores)I Have TRIED To Save/Load The DataStores And i Have Been Playing In A Play Solo Mode But Ill Try To Fix It With That Answer! Thanks!
ILL TRY to use arrays to save it! I will tell if it works or not but for now All i can say is "Thanks!" Hopefully you will visit this quetion again :D