Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this working?

What I want it to do is that if a player has their right arm off they can go through the door and people that have their right arm can't go through the door. Help me see what I am doing wrong.

local part = script.Parent

function onTouch(hit)
	local Player = hit.Parent
	if Player['Right Arm'] == nil then
		part.CanCollide = false
	end
end
part.Touched:connect(onTouch)

1 answer

✓ Accepted answer

Try findfirstchild

local part = script.Parent

function onTouch(hit)
    local Player = hit.Parent
    if Player:FindFirstChild("Right Arm") == nil then
        part.CanCollide = false
    end
end
part.Touched:connect(onTouch)

FindFirstChild returns nil if not found.

4 comments

0

Gosh Dangit I'll never be a good scripter :( I cant even figure out that would work. Thanks though

0

You'll learn eventually :P

0

I just have a question when I use the script even when I have a right arm it still lets me go through.

0

Nvm I figured it out I needed a else

This discussion is preserved as it was. New answers, comments, and votes are closed.