local char = game.Players.LocalPlayer.Character
pcall(function()
local DeletedWings = {
"Angel", -- Empyrean Reignment
"FireWings" --Wings of Fire
}
for index,value in ipairs(DeletedWings) do
local hatName = DeletedWings[index]
print(hatName)
while wait() do
local X = DeletedWings[index]
if char.X then --Errors here
char.hatName:Destroy()
end
end
end
end)
My goal is to loop through the array named DeletedWings until it detects a certain hat, then removes it. I believe it errors in the line "if char.X then", and I get the message "X is not a valid member of Model". I'm pretty sure that the script is searching for a "game.Players.LocalPlayer.Character.X" instead of a "game.Players.LocalPlayer.Character.Angel" How do I make the script use the variable's value (ie "Angel" or "FireWings" instead of its name?

3 comments
Change it to 'if X then'. It's searching for an object called 'X' in the character, not checking to see if X exists.
Also, I don't see that
whileloop terminating ever.If you're trying to find an object with the name of X, you should use char:FindFirstChild(X).