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

What do I do?

I just used this script so that when you have your right arm off you go through the door but when I have my left arm and right arm off I still go through the door. Is there anyway to fix that?

This is the code.

local part = script.Parent

part.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = hit.Parent
        
        if not player:FindFirstChild("Right Arm") then
            part.CanCollide = false
            part.Transparency = 0.6
            
            wait(2)
            
            part.Transparency = 0
            
        else
            local humanoid = player:FindFirstChild("Humanoid")
            
            if humanoid then
                humanoid:TakeDamage(humanoid.Health)
            end
        end
    end
end)

2 answers

You pretty much have it down, you just need to add another condition that checks if the left arm is there or not. To do that, we'll pretty much do what you already have, and just check both arms.


Your script should look like this:

local part = script.Parent

--[]

--Change the ones that need to be OFF to true
--Change the ones that need to stay ON to false
local LeftArm = false
local RightArm = true
local LeftLeg = false
local RightLeg = false

--[]

function CheckLimbs(player)
	local CheckCount = 0
	if (LeftArm == true and not player:FindFirstChild("Left Arm")) or (LeftArm == false and player:FindFirstChild("Left Arm")) then
		CheckCount = CheckCount+1
	end
	if (RightArm == true and not player:FindFirstChild("Right Arm")) or (RightArm == false and player:FindFirstChild("Right Arm")) then
		CheckCount = CheckCount+1
	end
	if (LeftLeg == true and not player:FindFirstChild("Left Leg")) or (LeftLeg == false and player:FindFirstChild("Left Leg")) then
		CheckCount = CheckCount+1
	end
	if (RightLeg == true and not player:FindFirstChild("Right Leg")) or (RightLeg == false and player:FindFirstChild("Right Leg")) then
		CheckCount = CheckCount+1
	end
	if CheckCount==4 then
		return true
	else
		return false
	end
end

part.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = hit.Parent

        if CheckLimbs(player) then
            part.CanCollide = false
            part.Transparency = 0.6

            wait(2)

            part.Transparency = 0

        else
            local humanoid = player:FindFirstChild("Humanoid")

            if humanoid then
                humanoid:TakeDamage(humanoid.Health)
            end
        end
    end
end)

So now it should work how you wanted. If you have any further problems or questions, leave a comment below, and I'll see what I can do. Hope I helped :P

####-Dyler3

local part = script.Parent

part.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = hit.Parent

        if not player:FindFirstChild("Right Arm") and player:FindFirstChild("LeftArm") then
            part.CanCollide = false
            part.Transparency = 0.6

            wait(2)

            part.Transparency = 0

        else
            local humanoid = player:FindFirstChild("Humanoid")

            if humanoid then
                humanoid:TakeDamage(humanoid.Health)
            end
        end
    end
end)

Here.

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