So what I am doing is trying to make a localscript where it seeks the classification of the keycard and then if the prompt gets triggered, this seeks searches if the player has the correct clearance and sends information to the actual script that opens the door and etc.
But why I am doing this by a remote event? Because I would have two models with same name and to prevent to fix the clearance every time in these 2 scripts, I decided to make a localscript which verifies the clearance and sends that same info to the actual script so I can fix the clearance just one time than two times.
However, for some reason, the script isn’t detecting any prints or working and have no ideia of how to make this work.
local LocalPlayer = game:GetService("Players").LocalPlayer
local Model = script.Parent
local EventDoor = Model.AutoDoor
local Clearance = {
"Officer",
"Board of Directors",
"Board of Overseers",
}
for _, prompt in pairs(Model:GetDescendants()) do
print("Searching for Prompts")
if prompt:IsA("ProximityPrompt") and prompt.Name == "NormalPrompt" then
print("Prompt found")
local function ClearClearance()
local Character = LocalPlayer.Character
if Character then
print("Character Found")
for _, item in pairs(Character:GetDescendants()) do
if table.find(Clearance, item.Name) then
EventDoor:FireServer()
print("Script sent")
end
end
else
print("Character not found, searching...")
wait(0.1)
ClearClearance()
end
end
prompt.Triggered:Connect(ClearClearance)
end
end