I want to make a keycard for this door, but I don't know how to make the keycard. Heres the script for the door when you use the card to open it.

local light = script.Parent.Parent.Parent.Light
local DB = script.Parent.Parent.Parent.DB
local Door = script.Parent.Parent.Parent.Door
function Close()
for i=1, 49 do

wait(0.001)
Door.CFrame = Door.CFrame * CFrame.new(0, 0, -0.1)

end
end

function Open()
for i=1, 49 do

wait(0.001)
Door.CFrame = Door.CFrame * CFrame.new(0, 0, 0.1)

end

end

function Touch(hit)

	if ((string.find(hit.Parent.Name, "Card")) ~= nil) then
		if (hit.Parent.Code.Value == script.Parent.Parent.Parent.Serial.Value) or (hit.Parent.Code.Value == 0) then -- 0 is universal lock.
			if DB.Value == false then
				DB.Value = true
				light.BrickColor = BrickColor.new("Bright green")
				Open()
				wait(10)
				Close()
				light.BrickColor = BrickColor.new("Black")
				wait(1)
				DB.Value = false
			end
		end
	end
end

script.Parent.Touched:connect(Touch)

1 comment

1

Please fix the Lua code showing because some of the code is showing outside of the code block. Thanks!