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

I want this door to only open with a keycard, it opens with an arm though. How to fix?

The door is supposed to only open when the keycard touches, but it's also opening with a player's arm. How do I stop this? Here is the script:

							--<tkcmdr>--

local door = script.Parent
local bool = true
local bool2 = true
local clearance = {
	["Omni"] = true,
	["MTF"] = true,
	["L5"] = true, 
	["L4"] = true,
	["L3"] = true,
	["L2"] = true,
	["L1"] = false,
}

function openDoor()
	script.Parent.DoorOpen:play()
	for i = 1,(door.Size.z / 0.30) do
		wait()
		door.CFrame = door.CFrame - (door.CFrame.lookVector * 0.30)
	end
	wait(3)
	script.Parent.DoorClose:play()
	for i = 1,(door.Size.z / 0.30) do
		wait()
		door.CFrame = door.CFrame + (door.CFrame.lookVector * 0.30)
	end
end

script.Parent.Parent.KeycardReader1.touched:connect(function(touch)
	if touch.Name == "Handle" and clearance[touch.Parent.Name] and bool then
		bool = false
		script.Parent.AccessGranted:play()
		script.Parent.Parent.Light1.brickColor = BrickColor.new("Bright green")
		script.Parent.Parent.Light2.brickColor = BrickColor.new("Bright green")
		openDoor()
		wait(1)
		script.Parent.Parent.Light1.brickColor = BrickColor.new("Bright red")
		script.Parent.Parent.Light2.brickColor = BrickColor.new("Bright red")
		bool = true
	elseif touch.Name == "Handle" and not clearance[touch.Parent.Name] and bool2 then
		bool2 = false
		script.Parent.AccessDenied:play()
		wait(1)
		bool2 = true
	end
end)

script.Parent.Parent.KeycardReader2.touched:connect(function(touch)
	if touch.Name == "Handle" and clearance[touch.Parent.Name] and bool then
		bool = false
		script.Parent.AccessGranted:play()
		script.Parent.Parent.Light1.brickColor = BrickColor.new("Bright green")
		script.Parent.Parent.Light2.brickColor = BrickColor.new("Bright green")
		openDoor()
		wait(1)
		script.Parent.Parent.Light1.brickColor = BrickColor.new("Bright red")
		script.Parent.Parent.Light2.brickColor = BrickColor.new("Bright red")
		bool = true
	elseif touch.Name == "Handle" and not clearance[touch.Parent.Name] and bool2 then
		bool2 = false
		script.Parent.AccessDenied:play()
		wait(1)
		bool2 = true
	end
end)

1 answer

Your keycard script doesn't seem to have any problems, and because of that I will assume that the reason you think your keycard is opening to peoples arms is because the keycard is actually bigger than you think. I would suggest resizing the Handle part in the keycard to something smaller than what it is and then giving it another shot.

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