I’ve attempted to make keycard readers that work as follows : keycard one activated, keycard two deactivated until keycard one’s tween is completed, which you should then be able to activated keycard one or two again, depending on which side of the keycard door you’re on. However, instead it deactivates keycard one until you use keycard two, which deactivates keycard two until you use keycard one.
I’ve attempted to rectify this by playing around with the addtags and removetags, but to no avail… So I’m wondering what exactly I can do to fix this.
Keycardreader Two
--
function onTouched(dir)
if busy then return end
if keycardOne:HasTag(0) then
local char = dir.Parent;
local hum = char:FindFirstChildOfClass("Humanoid");
if hum then
local keycard = char:FindFirstChild("Keycard");
if keycard then
local gateTween = ts:Create(gate, gateTi, properties)
keycardOne:AddTag(0)
keycardReader:RemoveTag(0)
busy = true
keycardReader.BrickColor = BrickColor.new("Lime green")
gateTween:Play()
gateTween.Completed:Connect(function(PlaybackState)
if PlaybackState == Enum.PlaybackState.Completed then
busy = false
keycardReader.BrickColor = BrickColor.new("Medium stone grey")
keycardReader:AddTag(0)
keycardOne:RemoveTag(0)
end
end)
end
end
end
end
script.Parent.Touched:Connect(onTouched);
Keycardreader One
-- function onTouched(dir)
if busy then return end
if keycardTwo:HasTag(0) then
local char = dir.Parent;
local hum = char:FindFirstChildOfClass("Humanoid"); --If a humanoid is present, a character touched it.
if hum then
local keycard = char:FindFirstChild("Keycard"); --Find a keycard
if keycard then
local gateTween = ts:Create(gate, gateTi, properties)
keycardTwo:AddTag(0)
keycardReader:AddTag(0)
busy = true
keycardReader.BrickColor = BrickColor.new("Lime green")
gateTween:Play()
gateTween.Completed:Connect(function(PlaybackState)
if PlaybackState == Enum.PlaybackState.Completed then
busy = false
keycardReader.BrickColor = BrickColor.new("Medium stone grey")
keycardReader:AddTag(0)
keycardTwo:RemoveTag(0)
end
end)
end
end
end
end
script.Parent.Touched:Connect(onTouched);