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)