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!
Check the spelling of "GetAsync"
It's Async, not Asnyc.
"Async" is short for "Asynchronous" which means the function will yield the thread until it receives the data.
The method is named GetAsync
, not getAsync
Edit: Same applies to SetAsync