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

Why isnt my item description script not running my second for loop?

Asked by 2 years ago
local ItemRooms = {}

function LoadItems()
    local ItemFile = game.ReplicatedStorage.Items

    for _, v in pairs(workspace:GetDescendants()) do
        if v:IsA("Model") and v.Name == "ItemRoom" then
            local Item = ItemFile:GetChildren()
            local chosenItem = Item[math.random(1, #Item)]:Clone()
            chosenItem.Parent = v
            chosenItem:MoveTo(v.Pedastol.Position + Vector3.new(0, 1.5, 0))
            local Pedastol = v.Pedastol
            table.insert(ItemRooms, v)
        end
    end
end

LoadItems()

--//ItemDesc.
for _, v in pairs(ItemRooms) do
    local Peadastol = v.Pedastol
    Peadastol.Touched:Connect(function(p)
        if p:FindFirstChild("Humanoid") then
            for _, x in pairs(v:GetDescendants()) do -- doesnt run this loop
                print(x) -- doesnt print
                if x:IsA("Model") and game.ReplicatedStorage.Items:FindFirstChild(x.Name) then
                    local GUI = script.DescGUI:Clone()
                    local Desc = x:FindFirstChild("Description")
                    local Player = game.Players:FindFirstChild(p.Parent.Name)
                    GUI.Holder.Description.Text = Desc.Value
                    GUI.Holder.Item.Text = x.Name
                    GUI.Parent = Player.PlayerGui
                    wait(5)
                    GUI:Destroy()
                end
            end
        end
    end)
end
0
your looking for the humanoid in the part, not the part's parent. That would be the same as looking for the humanoid in, say, the LeftFoot. Change line 24 to if p.Parent:FindFirstChild("Humanoid") then the8bitdude11 358 — 2y
0
i am an idiot. I cant believe i missed that... tightanfall 110 — 2y

Answer this question