Proximity Prompt Script

I am currently trying to create a proximity prompt activated door.
The door is supposed to check if they have a keycard, then if they do the door opens.

The issue is the door not opening. But no errors are printed on output.

Script:

local ProximityPrompt = script.Parent
local Door = script.Parent.Parent.Parent.Parent.Parent.Door

ProximityPrompt.Triggered:Connect(function(player)
	if ProximityPrompt.ActionText == "Open" then
		if player.Character:FindFirstChild('Level_2') or player.Character:FindFirstChild('Level_3') or player.Character:FindFirstChild('Level_4') or player.Character:FindFirstChild('Raider') or player:FindFirstChild('Level_2') or player:FindFirstChild('Level_3') or player:FindFirstChild('Level_4') or player:FindFirstChild('Raider') then
			Door.Transparency = 1
			Door.CanCollide = false
			ProximityPrompt.ActionText = "Close"
			print(player.Name)
		end
	end
end)
5 Likes

What errors are being printed?

1 Like

I said no errors.

0 errors are being printed

1 Like

My apologies, reading is hard! :grin:

Have you tried print debugging to see what is firing and what is not?

What do you mean???

He means after every if and event statement you print() somethingto make sure it’s getting past

Ok. I will do that right now. Lets find out if it works.

Just place print statements through different parts of the script so you can see what is working and what isn’t.

local ProximityPrompt = script.Parent
local Door = script.Parent.Parent.Parent.Parent.Parent.Door

ProximityPrompt.Triggered:Connect(function(player)
	if ProximityPrompt.ActionText == "Open" then
		if player.Character:FindFirstChild('Level_2') or player.Character:FindFirstChild('Level_3') or player.Character:FindFirstChild('Level_4') or player.Character:FindFirstChild('Raider') or player:FindFirstChild('Level_2') or player:FindFirstChild('Level_3') or player:FindFirstChild('Level_4') or player:FindFirstChild('Raider') then
            print("Working") -- add these to test 
			Door.Transparency = 1
			Door.CanCollide = false

			ProximityPrompt.ActionText = "Close"
			print(player.Name)
		end
	end
end)

What are you trying to find? A tool? I think the problem is the FIndFirstChild spam, but you need to locate the problem

The problem is the following line:

if player.Character:FindFirstChild('Level_2') or player.Character:FindFirstChild('Level_3') or player.Character:FindFirstChild('Level_4') or player.Character:FindFirstChild('Raider') or player:FindFirstChild('Level_2') or player:FindFirstChild('Level_3') or player:FindFirstChild('Level_4') or player:FindFirstChild('Raider') then

Ah, I see, is it a tool? Because if youre finding the child navigate to the tools the player has (i think)

Yes.
I am trying to find if the person who activated it has a tool.

player.Character.Backpack:FindFirstChild('Level_2')

try this maybe?

Not just for level 2. I want it for level 2 through level 4

Sorry should of clarified* Just add backpack for each one

Did you get the ProximityPromptService?

local ProximityPromptService = game:GetService("ProximityPromptService")

Put this line of code at the start of your script. Let me know if it works.

I don’t want to use the service because I will be using proximity prompt for different things in the game. Not just for opening doors.

I think it is necessary to get the ProximityPromptService when working with ProximityPrompts. Educate me if i am wrong

you need to get the service to even use prompts, and you can use it for different things not just that script btw.

The service isn’t required.

You can do:

script.Parent.Triggered

I don’t mind making new scripts for everything I just need this fixed.