ProximityPrompt/Script won't work

I am currently making a game that has doors and I’m using a ProximityPrompt in order to interact with them.

However when I press E the script and the ProximityPrompt won’t work.

I have tried using youtube and searching up my problem on forums and have gotten no answer

Here is my script that I put inside the door.

local debounce = false
local open = script.Parent.Parent.OpenDoor.Value
local proximityPrompt = script.Parent

proximityPrompt.Triggered:Connect(function()
	if not debounce then
		debounce = true
		if open == true then
			open = false
			game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {CFrame = script.Parent.Parent.Parent.Door1.CFrame}):Play()
		else
			open = true
			game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {CFrame = script.Parent.Parent.Parent.Door2.CFrame}):Play()
		end
		wait(1.3)
		debounce = false
	end
end)
2 Likes

Have you tried putting print("proximity prompt works") or somerthing in the proximityPrompt.Triggered function and pressing E on the proximity prompt to see if it prints and to see if the function is working correctly?

I have put a print in the script and it didn’t show up in the output.

Replace the following line of code:

local open = script.Parent.Parent.OpenDoor.Value

with:

local open = script.Parent.Parent.OpenDoor

and add .Value at the end of every reference to the variable named “open”. Your issue is occurring because you cannot assign references to properties, to variables.

The script you sent didn’t work

Strange, that didn’t work either

the open is a value?

Yeah, the open is a value a bool value

just to be clear, do any errors show up in the output?

local debounce = false
local open = script.Parent.Parent.OpenDoor
local proximityPrompt = script.Parent

proximityPrompt.Triggered:Connect(function()
	if debounce == false then
		debounce = true
		if open.Value == true then
			open.Value = false
			game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {CFrame = script.Parent.Parent.Parent.Door1.CFrame}):Play()
		else
			open.Value = true
			game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {CFrame = script.Parent.Parent.Parent.Door2.CFrame}):Play()
		end
		wait(1.3)
		debounce = false
	end
end)

No errors show up no prints show up in the output

how about this

Then there’s likely some other issue at hand, I just noticed that issue straight away.

Yeah I tried that and it doesn’t work

I’m just not sure what that issue is that’s causing it

well did you check the open value is true

The open value is not true because the door is closed

maybe you could comment each variable out (expect proximityPrompt) one at a time and test the script to see if any of them are preventing the function from running

local debounce = false
local open = script.Parent.Parent.OpenDoor
local proximityPrompt = script.Parent

proximityPrompt.Triggered:Connect(function()
	print("works")
	--if not debounce then
	--	debounce = true
	--	if open.Value then
	--		open.Value = false
	--		game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {CFrame = script.Parent.Parent.Parent.Door1.CFrame}):Play()
	--	else
	--		open.Value = true
	--		game.TweenService:Create(script.Parent.Parent,TweenInfo.new(1.25,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {CFrame = script.Parent.Parent.Parent.Door2.CFrame}):Play()
	--	end
	--	wait(1.3)
	--	debounce = false
	--end
end)

I’m not sure why it’s not working anymore lol, if you find out which one you can uncomment the code by selecting it and pressing ctrl + /, and you could try to fix the thing that’s causing it

I have tried out what you said and it still doesn’t work. There must be something wrong with my game.

Can you send a screenshot of all the properties inside the proximity prompt?