local doorModel = script.Parent.Parent.Parent.Parent.Parent
local prompt = script.Parent
local prompt2 = doorModel.KeycardReader2.Func.KeycardRead.ProximityPrompt
local door1 = doorModel.Doors.Door1
local accept = script.Parent.Parent.Accept
local deny = script.Parent.Parent.Denied
-- > SETUP < --
local door2 = doorModel.Doors.Door2
local doorT1 = doorModel.Doors.TargetD1
local doorT2 = doorModel.Doors.TargetD2
local closePos1 = doorModel.Doors.Door1.Position
local closePos2 = doorModel.Doors.Door2.Position
local keycardLight1 = doorModel.KeycardReader1.Func.KeycardLight
local keycardLight2 = doorModel.KeycardReader2.Func.KeycardLight
local cards = {
["LightAccessKeycard"] = false,
["MediumAccessKeycard"] = true,
["HeavyAccessKeycard"] = true,
["HostileHackBypasser"] = true,
["AdminBypasser"] = true;
}
-- > TWEENING < --
local tweenService = require(game.ReplicatedStorage.TweenServicePlus)
local goal1 = {}
local goal2 = {}
local goalclose1 = {}
local goalclose2 = {}
goal1.Position = doorT1.Position
goal2.Position = doorT2.Position
goalclose1.Position = closePos1
goalclose2.Position = closePos2
local InfoD1 = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0)
local InfoD2 = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0)
local tweenD1 = tweenService:Construct(door1, InfoD1, {Position = goal1.Position})
local tweenD2 = tweenService:Construct(door2, InfoD2, {Position = goal2.Position})
local tweenClse1 = tweenService:Construct(door1, InfoD1, {Position = goalclose1.Position})
local tweenClse2 = tweenService:Construct(door2, InfoD2, {Position = goalclose2.Position})
-- > CODE < --
prompt.Triggered:Connect(function(plr)
local debounce = doorModel.IsMoving.Value
local char = plr.Character or plr.CharacterAdded:Wait()
print("No debounce.")
local plrBackpackContent = plr.Backpack:GetChildren()
print("Children obtained.")
local accepted = false
for i,tool in pairs(plrBackpackContent) do
print(tool.Name)
if cards[tool.Name] then
if debounce then return end
debounce = true
accept:Play()
print("Debounce check.")
print("Success!")
prompt.Enabled = false
prompt2.Enabled = false
keycardLight1.Color = Color3.fromRGB(26, 255, 0)
keycardLight2.Color = Color3.fromRGB(26, 255, 0)
tweenD1:Play(nil,1000)
tweenD2:Play(nil,1000)
tweenD1.Completed:Wait()
keycardLight1.Color = Color3.fromRGB(255, 0, 4)
keycardLight2.Color = Color3.fromRGB(255, 0, 4)
task.wait(2)
tweenClse1:Play(nil,1000)
tweenClse2:Play(nil,1000)
tweenClse1.Completed:Wait()
prompt.Enabled = true
prompt2.Enabled = true
debounce = false
accepted = true
break
elseif not accepted then
deny:Play()
print("Invalid card inserted by: "..plr.Name)
end
end
end)
This is the script.
It’s been making me go mad for so long. I don’t know what’s wrong. The issue is that the door plays allowed AND denied sounds if the player were to have several cards at once, e.g: allowed and denied card.
I’ve asked several people and times to help, none helped. I’m growing desperate to just keep it in as normally the players would have one card only, but I want to be safe.