Problem With Proximity Prompts

For some reason the prompt I have needs to be clicked twice to activate if anyone knows why please tell me

here is the code i wrote

local prompt = script.Parent
local Main = script.Parent.Parent
local Handle = script.Parent.Parent.Parent.Handle

prompt.Triggered:Connect(function()
	if Main.Position == Vector3.new(96.45, 28.583, 81.801) and 
		Main.Orientation == Vector3.new(0, 180, 0) and 
		Handle.Position == Vector3.new(95.319, 28.634, 81.962) and 
		Handle.Orientation == Vector3.new(90, 180, 0) then
	   
		Main.Position = Vector3.new(100.03, 28.583, 82.561)
		Handle.Position = Vector3.new(101.09, 28.634, 82.987)
		Main.Orientation = Vector3.new(0, -30, 0)
		Handle.Orientation = Vector3.new(90, -30, 0)
	else
		Main.Position = Vector3.new(96.45, 28.583, 81.801)
		Handle.Position = Vector3.new(95.319, 28.634, 81.962)
		Main.Orientation = Vector3.new(0, 180, 0)
		Handle.Orientation = Vector3.new(90, 180, 0)
	end
	

end)


heres a vid too

Could you try putting prints in the triggered function and in both if statements?

yes i did for some reason when I click it for the first time it prints door closed but its already closed and I cant seem to figure out why

do you know what I could possibly do?

Hello, usually Vector3s are not the same as seen in the “Property” window.

An example would be this:

[Property window] - [Logged Vector3]

To solve this issue, you’ll most likely need to print each position & orientation if necessary and fix your code according to the real values. Another way is just doing it with bool values and setting up the positions & orientations using operators.

1 Like

Yes, good suggestion it is much better to use boolean than victors value, also if he wants to detect if the door was closed or open it is much easier because boolean have only two choices true and false, also the door has only two choices open and close, so it matches perfectly unlike in victors so many possible values. Like when he change the position of the door the if statement have to change as well not to accurate.

Thanks I used booleans to specify if the door is closed or not and I made it work, for anyone wondering what I did exactly here is the script

local Main = script.Parent.Parent
local Handle1 = script.Parent.Parent.Parent.Handle1
local Handle2 = script.Parent.Parent.Parent.Handle2
local Handle3 = script.Parent.Parent.Parent.Handle3
local prompt = script.Parent
local Doorclosed = true

prompt.Triggered:Connect(function()
	if Doorclosed == true then
		
		print("it opened")
		Main.Position = Vector3.new(100.742, 30.35, 83.112)
		Main.Orientation = Vector3.new(0, -45, 0)
		Handle1.Position = Vector3.new(102.192, 31.15, 83.925) 
		Handle1.Orientation = Vector3.new(0, -135, 90) 
		Handle2.Position = Vector3.new(102.439, 30.05, 83.677)
		Handle2.Orientation = Vector3.new(0, -135, 90) 
		Handle3.Position = Vector3.new(102.192, 28.95, 83.925) 
		Handle3.Orientation = Vector3.new(0, -135, 90) 
		Doorclosed = false
	else if Doorclosed == false then
			Main.Position = Vector3.new(96.944, 30.35, 81.971)   
			Main.Orientation = Vector3.new(0, 180, 0) 
			Handle1.Position = Vector3.new(95.344, 31.15, 82.421) 
			Handle1.Orientation = Vector3.new(0, 90, 90) 
			Handle2.Position = Vector3.new(95.344, 30.05, 82.771) 
			Handle2.Orientation = Vector3.new(0, 90, 90) 
			Handle3.Position = Vector3.new(95.344, 28.95, 82.421) 
			Handle3.Orientation = Vector3.new(0, 90, 90) 
			Doorclosed = true
			
		end
    end
end)

2 Likes