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

why does my argument always come back nil?

Asked by 1 year ago
Edited 1 year ago
local Chest = Replicated.Clothes.Chest:GetChildren()

for i, v in pairs(Chest)do
            print(player.Character:FindFirstChild(v))
        end

so what I'm doing is checking if a player has an accessory on listed in the Chest folder but even when I should get a true statement it always comes back Nil

1 answer

Log in to vote
2
Answered by
0x5y 105
1 year ago

The :FindFirstChild() function will always return nil in your case, due to the fact that it only accepts a string Name as the input, and you are passing a value of type Instance. You can read more about it here.

In your case, you could do something like this:

local Chest = Replicated.Clothes.Chest:GetChildren()

for i, v in pairs(Chest) do
    if player.Character:FindFirstChild(v.Name) then
        print("player is wearing "..v.Name)
    else
        print("player is not wearing "..v.Name)
    end
end
0
oh my how did I look passed that I even thought about that thank you so much! TheMiniMagic_YT 27 — 1y
Ad

Answer this question