--//variables
local DataStoreService = game:GetService("DataStoreService")
local LevelStore = DataStoreService:GetDataStore("Levelllssss")
--//player added
game.Players.PlayerAdded:Connect(function(player)
--//creating level
local LevelFolder = Instance.new("Folder",player)
LevelFolder.Name = "LevelStore"
local Level = Instance.new("IntValue",LevelFolder)
Level.Name = "Level"
Level.Value = LevelStore:GetAsync(player.UserId,Level.Value)or 1
--//creating needed xp
local NeededXP = Instance.new("IntValue",LevelFolder)
NeededXP.Name = "NeededXP"
NeededXP.Value = LevelStore:GetAsync(player.UserId,NeededXP.Value)or 1000
--//creating current xp
local XPP = Instance.new("IntValue",LevelFolder)
XPP.Name = "XP"
XPP.Value = LevelStore:GetAsync(player.UserId,XPP.Value)or 0
--//main handling
local success,level = pcall(function()
return LevelStore:GetAsync(player.UserId,Level.Value,NeededXP.Value,XPP.Value)
end)
if success then
LevelStore:SetAsync(player.UserId,Level.Value,NeededXP.Value,XPP.Value) else
player:Kick("Data Error | Please rejoin!")
end
end)
--//Save when player leaves
game.Players.PlayerRemoving:Connect(function(player)
LevelStore:SetAsync(player.UserId,player.LevelStore.Level.Value,player.LevelStore.NeededXP.Value,player.LevelStore.XP.Value)
end)
So I started learning how to do datastores yesterday. Today I ran into a problem when trying to create my level system. When I first join the game, the values get set correctly. When I join the game for the second time to see if it all saved, it saves at one? Why is this? I'm new to datastores and kind of need help. I can't spot where it's all saving as 1.

9 comments
It's actually much neater. It's just on here that it kind of messes up with neatness
Is XPP saving at one as well?
Yeah it's saving on player leaving, it's cut off though and it's saving everywhere else
Oh, yes XPP is saving as one as well
"Levelllssss"
Please answer my question instead of commenting on the name of the datastore ;-; I had to keep changing it because of it saving weirdly...
oh srry
GetAsync only takes one parameter, the key. And as I see from your SetAsync below, your key is the player's userid. Try getting rid of the second parameters in GetAsyncs and check the specific part of the table you want.
And SetAsync only takes two parameters, so maybe you should turn everything after the userid into a table or dictionary