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)
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?
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.
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)
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