Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ServerScriptService.PlayerDSS:40: attempt to index local 'GetLevel' (a nil value) ?

Asked by 5 years ago

In a script, i've used the DataStoreService, to allow my game to save data. It perfectly works until the use of GetAsync.

Here's the part that doesnt work :

game.Players.PlayerAdded:Connect(function(player)

local plrID = "player_"..player.userId
local playerLevel = DSService:GetDataStore("plrLevel")

local GetLevel = playerLevel:GetAsync(plrID)

level.Value = GetLevel[1] or 1 -- this ain't working. Also, i did put the [1] to every values (GetExp[1] or 0 ; GetStamina[1] or 0 , etc....)

end)
0
the value you saved with SetAsync or UpdateAsync must be nil. you should be checking if GetLevel isnt nil before trying to index anything inside it Gey4Jesus69 2705 — 5y

Answer this question