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

Why isn't this working?

Asked by
duckyo01 120
9 years ago

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

Log in to vote
1
Answered by
NotSoNorm 777 Moderation Voter
9 years ago

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.

0
Gosh Dangit I'll never be a good scripter :( I cant even figure out that would work. Thanks though duckyo01 120 — 9y
0
You'll learn eventually :P NotSoNorm 777 — 9y
0
I just have a question when I use the script even when I have a right arm it still lets me go through. duckyo01 120 — 9y
0
Nvm I figured it out I needed a else duckyo01 120 — 9y
Ad

Answer this question