Okay, so I recently posted an error with my code a day or two ago, that turned out to be a spelling error -_-. Anyway, I have found yet *another* error.
The script is supposed to display the players level on the leaderboard. I'm not quite sure what's wrong, maybe you can help me figure it out. Here's the code:
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:getAsync(key) if DataStore:getAsync(key) == 0 then DataStore:setAsync(key, 1) local connection = DataStore:OnUpdate(key, function(value) player.leaderstats.levelstats.Value = DataStore:getAsync(key) end) end end)
Now, here's the error it's printing (in orange letters): 17:00:47.876 - "GlobalDataStore.getAsync" should be "GetAsync" in Workspace.Leaderstats 17:00:48.195 - httpGet https://api.roblox.com/gametransactions/getpendingtransactions/?PlaceId=179245784&PlayerId=24031098 failed. Trying again. Error: HTTP 403 (Forbidden). Elapsed time: 0.314093
Please help me figure out what the problem is and fix it!
As stated by Merely and Tk, orange text in the output is not an error, but an exception. But, this exception will stop your script from showing the value of the key in the Data Store.
Lua is case sensitive so you only need to change getAsync
to GetAsync
and setAsync
to SetAsync
.
You could also clean up some of your code, too. Try this:
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:GetAsync(key) or 1 --If the result of GetAsync is nil, use 1 instead. DataStore:OnUpdate(key, function() player.leaderstats.levelstats.Value = DataStore:GetAsync(key) end) end end)
Those are both warnings. They don't break your code, but they're telling you that you're doing something wrong.
The first one says you should be using GetAsync instead of getAsync on line 11.
The second one is unrelated to your DataStore and you can ignore it.