LocalScript doesn't search for ProximityPrompts / Doesn't send any print information

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
2 Likes

Still need a response!!!
!!!

2 Likes

is the script in the player? that is the only time a local script has refused to work for me (it needs to be in the player)

1 Like

No, it’s on the model, I’ll send an image. (The script where I am getting the problems is from LocalScript)

image

2 Likes

sadly local scripts don’t even run if they aren’t in a player so you are going to need to go with a regular script

(I have run into this way too many times to count)

1 Like

Like someone already said above, a local script won’t work if it’s not inside of the player, so if your model is in workspace it won’t work. You have to put it somewhere that gets put into the player like StarterPlayer or use a normal script.

2 Likes