I have the following code:
local door = script.Parent local allowed = {"boogieboon", "someothername"} door.touched:connect(function(hit) local character = hit.Parent if character.Humanoid then for i,v in pairs(allowed) do if character.Name == v then door.Transparency = 1 door.CanCollide = false wait(1) door.Transparency = 0 door.CanCollide = true end end end end)
I was just wondering why the output keeps returning "Humanoid is not a valid member of Accessory" for line 6 even though I have an if statement that is supposed to deal with what to do if it doesn't have a humanoid in it? It's not a game-breaking problem but I would just like to know how to prevent the output from erroring since I'm trying to deal with this error in the if statement. Thanks, Any help is appreciated.
Your accessories are hitting the door instead of your body parts. Accessories are "set up" so that there's the accessory container and then a handle inside of it that actually comes in contact with other objects.
You need to add a debug piece so that if the character is nil you search for hit.Parent.Parent.
if humanoid == nil then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end
^ something like that.
local door = script.Parent local allowed = {"boogieboon", "someothername"} door.Touched:Connect(function(hit) local character = hit.Parent if character.Humanoid then for i,v in pairs(allowed) do if character.Name == v then door.Transparency = 1 door.CanCollide = false wait(1) door.Transparency = 0 door.CanCollide = true end end end end)