So, I'm trying to make a leaderboard where it displays the level of a player using the script below:
local DataStore = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
local levelstats = Instance.new("IntValue", leaderstats)
levelstats.Name = "Level"
local key = "user_" .. player.userId
player.leaderstats.Level.Value = DataStore:getAsnyc(key)
if DataStore:getAsnyc(key) == 0 then
DataStore:setAsync(key, 1)
local connection = DataStore:OnUpdate(key, function(value)
player.leaderstats.levelstats.Value = DataStore:getAsnyc(key)
end)
end
end)
Whenever I run it, I get this error: 16:32:21.444 - getAsnyc is not a valid member of GlobalDataStore 16:32:21.445 - Script 'Workspace.Leaderstats', Line 13
What's wrong with the script? I have found no reason why getAsnyc would not work for DataStore. Please help me!

1 comment
I think you have an unnecessary space in line 13. Remove the space after the two dots, so it would be ..player.userId