I need help with scripting an access control system

You can write your topic however you want, but you need to answer these questions:
Achievement: I want to make a system that opens a gate when I scan a card or press an exit button

Issue: The issue is that it the gate does not open due to the BindableFunction.

Tried Solutions: I tried matching the ZoneID with the correct keying on both the FolderRelay script and the central panel’s RelayScript which communicates over the system’s BindableFunction to the folder’s relay script.

Hierachy image:

Scripts:
Folder Relay:
local SysAPI = script.Parent.Parent.Parent.Parent.EntryControlAPI
local zoneIdentifier = script.ZoneIdentifier
– Config
local OpenTime = 9 – seconds
– Main Code (DO NOT TOUCH)
local function Req(cmd,ZoneID)
if zoneIdentifier.Value == ZoneID then
if cmd == “ZoneOpen” then
print("FolderRelay Received Command: " … cmd)
print("FolderRelay Received ZoneID: " … ZoneID)
script.Parent.IsOpen.Value = true
wait(OpenTime)
script.Parent.IsOpen.Value = false
end
end
end

SysAPI.OnInvoke = Req

Central Cabinet’s RelayScript
local SysAPI = script.Parent.Parent.Parent.EntryControlAPI
local debounce = false
local function OnSysInvoke(cmd, ZoneID)
if cmd == “ReaderOpen” then
if debounce == false then
debounce = true
print("Sent Command: " … cmd)
print("Sent ZoneID: " … ZoneID)
wait(0.1)
debounce = false
SysAPI:Invoke(“ZoneOpen”,ZoneID)
end
end
end

SysAPI.OnInvoke = OnSysInvoke
Reader Script
local SysAPI = script.Parent.Parent.Parent.Parent.Parent.EntryControlAPI
local ClickDetector = script.Parent.ButtonWithGhosts.Button.ClickDetector
– Config
local ZoneConfigFolder = script.Parent.Parent.Parent.ZoneConfig
local ZoneID = ZoneConfigFolder.ZoneID
– Main Code
local function ExitPressed()
script.Parent.ButtonWithGhosts.Button.Transparency = 1
script.Parent.ButtonWithGhosts.InGhost.Transparency = 0
script.Parent.Faceplate.ButtonFX:Play()
wait(0.09)
script.Parent.ButtonWithGhosts.Button.Transparency = 0
script.Parent.ButtonWithGhosts.InGhost.Transparency = 1
SysAPI:Invoke(“ReaderOpen”,ZoneID.Value)
end

ClickDetector.MouseClick:Connect(ExitPressed)

Actuator Script
– Config
local openpos = 0
local closepos = -1.3
local IsOpenBoolean = script.Parent.Parent.IsOpen
local PRC = script.Parent.RodShroud.PrismaticConstraint
local function BoolChanged()
if IsOpenBoolean.Value == true then
PRC.TargetPosition = openpos
else
PRC.TargetPosition = closepos
end
end

IsOpenBoolean.Changed:Connect(BoolChanged)

Detailed Explanation
When I scan my card or press the exit button, the door does not open, nor the piston retracts.
Output Log
Sent Command: ReaderOpen - Server - RelayScript:7 Sent ZoneID: 1 - Server - RelayScript:8
Responses
RelayScript: yes
FolderRelay: no
Info
Communications instance: BindableFunction
Zone open control: BoolValue

Can you pls format your code with

```lua 
Your code

```

1 Like