First Prompt not working but second trigger is?

I don’t really understand why this isn’t working as it should but here is the deal.

When the player first triggers the prompt, the doors doesn’t move (doesn’t close or open) and random sounds are played or all of them somehow. But after the second trigger (and more after) works completely fine, it’s just the first trigger that it doesn’t work properly.

ServerScript:

--// Services
local TweenService = game:GetService("TweenService")
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--// Models:Folders
local model = script.Parent.Parent.Parent.Parent
local customEvents = ReplicatedStorage:WaitForChild("CustomEvents")
local config = model:WaitForChild("Config")
local prompts = model:WaitForChild("Prompts")

--// Locals
local door1 = model:WaitForChild("Door1")
local door2 = model:WaitForChild("Door2")
local event = customEvents:WaitForChild("RemoteThought")
local prompt1 = prompts:WaitForChild("NorPrompt"):WaitForChild("CustomPrompt")

--// Sounds
local frame = model:WaitForChild("Frame")
local openSound = frame:WaitForChild("Open")
local closeSound = frame:WaitForChild("Close")

--// Configs
local isCooldown = config:WaitForChild("isCooldown")
local isOpen = config:WaitForChild("isOpen")

--// Configs:Locals
local text = "I'll wait a little, I guess."

--// TweenService
local open1 = {CFrame = door1.CFrame * CFrame.new(0, 0, 1)} 
local close1 = {CFrame = door1.CFrame}  
local open2 = {CFrame = door2.CFrame * CFrame.new(0, 0, -1)} 
local close2 = {CFrame = door2.CFrame}


local info = TweenInfo.new(1)
local door1Open = TweenService:Create(door1, info, open1)
local door1Close = TweenService:Create(door1, info, close1)
local door2Open = TweenService:Create(door2, info, open2)
local door2Close = TweenService:Create(door2, info, close2)

--// Functions
function doorSystem(plr)
	if isCooldown.Value == false then
		isCooldown.Value = true
		if isOpen.Value == true then
			door1Close:Play()
			door2Close:Play()
			closeSound:Play()
			door1Close.Completed:Wait()
			wait(1)
			isOpen.Value = false
			isCooldown.Value = false
		else
			if isOpen.Value == false  then
				door1Open:Play()
				door2Open:Play()
				openSound:Play()
				door1Open.Completed:Wait()
				wait(1)
				isOpen.Value = true
				isCooldown.Value = false
			end
		end
	end
end

prompt1.Triggered:Connect(function(plr: Player)
	if isCooldown.Value == false then
		doorSystem(plr)
	else 
		if isCooldown.Value == true then
			event:FireClient(plr, text)
		end
	end
end)


That kind of weird script.
I dont see point of second if here aswell.
It could be that value “isCooldown” originally being true?

You probably have softlocked debounce somewhere in code
Anyway:

prompt1.Triggered:Connect(function(plr: Player):()
	if isCooldown.Value == false then
		doorSystem(plr)
	else 
		event:FireClient(plr, text)
	end
end)

That could fix it i suppose?
(check for softlocking of debounce)

No, the issue still continues. There is no errors or anything in the output. (also sorry for the late response)

removed the if as well from the function, the issue still happens

--// Functions
function doorSystem()
	if isCooldown.Value == false then
		isCooldown.Value = true
		if isOpen.Value == true then
			door1Close:Play()
			door2Close:Play()
			closeSound:Play()
			door1Close.Completed:Wait()
			wait(1)
			isOpen.Value = false
			isCooldown.Value = false
		else
			door1Open:Play()
			door2Open:Play()
			openSound:Play()
			door1Open.Completed:Wait()
			wait(1)
			isOpen.Value = true
			isCooldown.Value = false
		end
	end
end

You made impossible to reach code
Bravo

Just remove if after else and it should work fine

Also it could be simply that isCooldown.Value is true by default
There so its softlocked
also remove if check here too
image

Overall you did code kinda poorly no offense

It all could’ve been simplified:

if isCooldown.Value == true then return end

and that it