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

chosen item coming back with argument missing or nil?

Asked by 3 years ago
Edited 3 years ago
local function LoadItems()
    for _, v in pairs(workspace:GetDescendants()) do
        if v:IsA("Model") and v.Name == "ItemRoom" then
            if not v:FindFirstChild("Item") then
                print("no item bool")
                local ItemBool = Instance.new("BoolValue")
                ItemBool.Name = "Item"
                ItemBool.Parent = v
                local ItemFind, i = chooseRandomItem()
                local chosenItem = ReplicatedStorage.Items:FindFirstChild(ItemFind) -- err here...
                local ClonedItem = chosenItem:Clone()
                ClonedItem.Parent = v
                ClonedItem:SetPrimaryPartCFrame(v.ItemLocation.CFrame)
                ItemDesc()
                if chosenItem:FindFirstChild("OneUse") then
                    table.remove(Items,i)
                    end
                    end
                end
            end
        end

idk why im getting an Argument 1 missing or nil...

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try this in the line 10 :

if ReplicatedStorage:FindFirstChild(Items).ItemFind == nil then --,,,,,,

Or

ReplicatedStorage:FindFirstChild(Items):FindFirstChild(ItemFind) 

Note : I am not a pro so don't judge me if it doesn't work.. I started learning Lua about just 2 Weeks ago

0
I meant to delete my answer. The issue was, the way I would choose an item based on rarity it wouldnt reset so it would try to pick the item again but the item is nil because there was nothing in the table for it. tightanfall 110 — 3y
0
Well good thing you fixed it :D Then accept my ans To give us rewards and close the page Hamoodiyt 26 — 3y
Ad

Answer this question