Proximity Prompt Doors Work in Roblox Studio But not in Roblox

You can write your topic however you want, but you need to answer these questions:

  1. What do I want to achieve?
    A Openable door using proximity prompts that doesn’t only work in Studio

  2. What is the issue?
    I made a door that opens and closes using proximity prompts, but it only works in Roblox Studio, and does not work in Roblox

Roblox Studio:
RobloxStudioGame

Roblox:
RobloxGame

  1. What solutions have I tried so far?
  • Looking on the dev forum for answers.
  • Publishing my game so that maybe the roblox game isn’t on the same version as the roblox studio game.
  • Revamping the entire script, since its a very old one.

script in question

local TweenService = game:GetService("TweenService")
local Triggered = script.Parent.Triggered

local hinge1 = script.Parent:WaitForChild("Door1"):WaitForChild("Model"):WaitForChild("Hinge")
local hinge2 = script.Parent:WaitForChild("Door2"):WaitForChild("Model"):WaitForChild("Hinge")
local Prompt01 = script.Parent:WaitForChild("Door1"):WaitForChild("Model"):WaitForChild("DoorHandle1"):WaitForChild("ProximityPrompt")
local Prompt02 = script.Parent:WaitForChild("Door1"):WaitForChild("Model"):WaitForChild("DoorHandle2"):WaitForChild("ProximityPrompt")
local Prompt1 = script.Parent:WaitForChild("Door2"):WaitForChild("Model"):WaitForChild("DoorHandle1"):WaitForChild("ProximityPrompt")
local Prompt2 = script.Parent:WaitForChild("Door2"):WaitForChild("Model"):WaitForChild("DoorHandle2"):WaitForChild("ProximityPrompt")

local SFXOpen1 = script.Parent:WaitForChild("Door1"):WaitForChild("Model"):WaitForChild("Door"):WaitForChild("Open")
local SFXClose1 = script.Parent:WaitForChild("Door1"):WaitForChild("Model"):WaitForChild("Door"):WaitForChild("Close")

local SFXOpen2 = script.Parent:WaitForChild("Door2"):WaitForChild("Model"):WaitForChild("Door"):WaitForChild("Open")
local SFXClose2 = script.Parent:WaitForChild("Door2"):WaitForChild("Model"):WaitForChild("Door"):WaitForChild("Close")

local goalOpen1 = {}
goalOpen1.CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-75), 0)

local goalOpen2 = {}
goalOpen2.CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(75), 0)

local goalClose1 = {}
goalClose1.CFrame = hinge1.CFrame * CFrame.Angles(0, 0, 0)

local goalClose2 = {}
goalClose2.CFrame = hinge2.CFrame * CFrame.Angles(0, 0, 0)

local tweenInfo1 = TweenInfo.new(1.5)
local tweenOpen1 = TweenService:Create(hinge1, tweenInfo1, goalOpen1)
local tweenClose1 = TweenService:Create(hinge1, tweenInfo1, goalClose1)

local tweenInfo2 = TweenInfo.new(1.5)
local tweenOpen2 = TweenService:Create(hinge2, tweenInfo2, goalOpen2)
local tweenClose2 = TweenService:Create(hinge2, tweenInfo2, goalClose2)

Prompt01.Triggered:Connect(function()
	if Triggered.Value == true then
		tweenClose1:Play()
		tweenClose2:Play()
		Triggered.Value = false
		Prompt01.ActionText = "Open"
		Prompt02.ActionText = "Open"
		Prompt1.ActionText = "Open"
		Prompt2.ActionText = "Open"
		SFXClose1:Play()
		SFXClose2:Play()
	else
		Triggered.Value = true
		tweenOpen1:Play()
		tweenOpen2:Play()
		Prompt01.ActionText = "Close"
		Prompt02.ActionText = "Close"
		Prompt1.ActionText = "Close"
		Prompt2.ActionText = "Close"
		SFXOpen1:Play()
		SFXOpen2:Play()
	end
end)

Prompt02.Triggered:Connect(function()
	if Triggered.Value == true then
		tweenClose1:Play()
		tweenClose2:Play()
		Triggered.Value = false
		Prompt01.ActionText = "Open"
		Prompt02.ActionText = "Open"
		Prompt1.ActionText = "Open"
		Prompt2.ActionText = "Open"
		SFXClose1:Play()
		SFXClose2:Play()
	else
		Triggered.Value = true
		tweenOpen1:Play()
		tweenOpen2:Play()
		Prompt01.ActionText = "Close"
		Prompt02.ActionText = "Close"
		Prompt1.ActionText = "Close"
		Prompt2.ActionText = "Close"
		SFXOpen1:Play()
		SFXOpen2:Play()
	end
end)

Prompt1.Triggered:Connect(function()
	if Triggered.Value == true then
		tweenClose1:Play()
		tweenClose2:Play()
		Triggered.Value = false
		Prompt01.ActionText = "Open"
		Prompt02.ActionText = "Open"
		Prompt1.ActionText = "Open"
		Prompt2.ActionText = "Open"
		SFXClose1:Play()
		SFXClose2:Play()
	else
		Triggered.Value = true
		tweenOpen1:Play()
		tweenOpen2:Play()
		Prompt01.ActionText = "Close"
		Prompt02.ActionText = "Close"
		Prompt1.ActionText = "Close"
		Prompt2.ActionText = "Close"
		SFXOpen1:Play()
		SFXOpen2:Play()
	end
end)

Prompt2.Triggered:Connect(function()
	if Triggered.Value == true then
		tweenClose1:Play()
		tweenClose2:Play()
		Triggered.Value = false
		Prompt01.ActionText = "Open"
		Prompt02.ActionText = "Open"
		Prompt1.ActionText = "Open"
		Prompt2.ActionText = "Open"
		SFXClose1:Play()
		SFXClose2:Play()
	else
		Triggered.Value = true
		tweenOpen1:Play()
		tweenOpen2:Play()
		Prompt01.ActionText = "Close"
		Prompt02.ActionText = "Close"
		Prompt1.ActionText = "Close"
		Prompt2.ActionText = "Close"
		SFXOpen1:Play()
		SFXOpen2:Play()
	end
end)

I couldn’t figure out what was wrong. However, I HIGHLY recommend you rewrite your code for getting the ProximityPrompts and other things. You should never use :WaitForChild() or any methods like that so many times in a row.

Mind checking your ingame console for errors?

It works in studio, so there can’t be any errors. I also had an experience with this. It’s due to how your code is structured.

True, but it wouldn’t hurt to check if something wasn’t properly being loaded via print statements and debugging from on roblox

I checked and nothing popped up

@Kasuki_ovo @KeegansPerun Here’s the file if yall wanna take a closer look at the model:
DualDoor.rbxm (61.6 KB)

Ok for some reason, the doors only open when the script uses “proximityprompt.TriggerEnded”. Why? no idea.

I uploaded the game myself and, while it worked, I managed to have 2 overlapping tweens at the same time. It looks like an issue with debounce, that is, you are simultaneously triggering 2 or more prompts at the same time and/or the same prompt twice. This may be due to client-server lag.

Second of all, this is a server script. Server scripts do not need WaitForChild(), as you normally only wait for items on client. The only exception would be the server waiting for something to spawn. For example an enemy, spawned from the other server script. But that is a very niche case, and can usually be avoided.

Anyways for the debounce fix:

local debounce = false
local TIMEOUT = 3 --in seconds

Prompt01.Triggered:Connect(function()

	if debounce then return end
	debounce = true
	task.delay(TIMEOUT, function() debounce = false end)

	if Triggered.Value == true then

Add the same debounce section to EACH of the remaining 3 functions.

Hope this helps.