Issue has been solved. No more assistance needed.
The error means that the function :FindFirstChild()
's first argument is nil
. We can decipher from line 74 that directory will always exist, which means that toolName
does not exist.
You should check your remotes.EquipItem:FireServer()
line to validate whether you’re properly sending a tool name or not.
function Shop.BuyAll()
local list = if currentShop == "Food" then toolConfig else dnaConfig
for _, toolTable in ipairs(list) do
if not ownsItem(toolTable.ID, currentShop) then
if toolTable.Price <= player.leaderstats.Coins.Value then
local result = remotes.Shop.ShopBuy:InvokeServer(toolTable.ID, currentShop)
if result == "PURCHASED" then
refreshGUI(toolTable.ID)
end
else
print("Player does not have enough money to proceed.")
break
end
end
end
local bestItem = bestItem
remotes.EquipItem:FireServer(bestItem, currentShop)
refreshGUI(bestItem)
end
if bestItem
is nil
then that would cause your current issue. There’s no way for me to tell you how it’s being set to nil with the given information though.
Edit: I’d also like to point out that the way you’re using bestItem
is not the best practice. You should change the local variable’s name to something else.
I fixed the issue, but I appreciate your patience because I made an restriction (it was supposed to do that but I forgot to make it not give out an error message). That prevented it from working and forgot about it because it was so late.