So I'm currently making a Vest system for my game and the script that handles the system has a table that will list out multiple vests, and the script has to check if the player is currently wearing a vest that is listed within the table, but I have no idea how I would do that.
What I currently have
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
---PlayerHealth
local MaxHealth = Humanoid.MaxHealth
local Health = Humanoid.Health
local Vests = {
["TanVest"] = Character:GetChildren("TanVest"),
["BlackVest"] = Character:GetChildren("BlackVest")
}
if Character:WaitForChild(Vests) then --I have gotten confused here on how I would check if a player has one of the 2 listed vests.
local HealthAdd = Character:FindFirstChild(Vests).HealthAdd
MaxHealth += HealthAdd.Value
Health += HealthAdd.Value
elseif not Character:WaitForChild(Vests) then --I have gotten confused here on how I would check if a player has one of the 2 listed vests.
print("Player does not have a Vest.")
end
end)
end)

8 comments
Use FindFirstChild() instead of WaitForChild()
I tried this a bit ago even with the vest on it still returns "Player does not have a Vest.".
Why are you putting a string inside of the GetChildren function? GetChildren only returns a table of children. In your case Character:GetChilden() returns a table with all the children of the character model
findfirstchild(nameofyourvest not vests because vests is a table), getchildren() not Children("TanVest"),GetChildren("BlackVest")
MarkedTomato you wrong model:moveto() differ from humanoid:Moveto()
@lehoaiquoc248 What are you talking about. I'm saying that GetChildren has no parameters
@lehoaiquoc248"findfirstchild(nameofyourvest not vests because vests is a table), getchildren() not Children("TanVest"),GetChildren("BlackVest")" I don't understand what you mean. Explain please
@lehoaiquoc248" MarkedTomato you wrong model:moveto() differ from humanoid:Moveto()" This guy wants to check if a player has a vest. Why are you talking about this?