script error @qb-core/client/loops.lua:15: attempt to index a nil value (field ‘metadata’)

Hello!
I’ve been messing around with my server and got his error after ensuring qb-core in the console!
Everything works fine until I do “ensure qb-core” again and I get this error.

I’ve tried google but all other topics seem dead with no answers.
I have tried deleting and re-adding the qb-core folder and I have the same issue, I’ve also tired starting without any other scripts running other than the qb-core ones.

This is the code in my loop.lua:

CreateThread(function()
while true do
local sleep = 0
if LocalPlayer.state.isLoggedIn then
sleep = (1000 * 60) * QBCore.Config.UpdateInterval
TriggerServerEvent(‘QBCore:UpdatePlayer’)
end
Wait(sleep)
end
end)

CreateThread(function()
while true do
if LocalPlayer.state.isLoggedIn then
if (QBCore.PlayerData.metadata[‘hunger’] <= 0 or QBCore.PlayerData.metadata[‘thirst’] <= 0) and not (QBCore.PlayerData.metadata[‘isdead’] or QBCore.PlayerData.metadata[“inlaststand”]) then
local ped = PlayerPedId()
local currentHealth = GetEntityHealth(ped)
local decreaseThreshold = math.random(5, 10)
SetEntityHealth(ped, currentHealth - decreaseThreshold)
end
end
Wait(QBCore.Config.StatusInterval)
end
end)

Any ideas would be greatly appreciated! <3

Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.