Event system firing but not receiving until 2nd attempt

I need the system I have set up so the script I have receives the event on the 1st attempt.


The 1st attempt at clicking the button ^^

The 2nd attempt ^^
As you can see, the event is not received on the first, but second attempt, and on the second attempt the event is received before it is fired.

I tried putting the event in ReplicatedStorage, tweaking my scripts, but I had no luck. I couldn’t find a topic similar to this one.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local button = script.Parent
local canFire = true

local openDoorEvent = game.ReplicatedStorage.openEvent
print("Variables set")

button.MouseClick:Connect(function()
	local missileToFire = game.ReplicatedStorage.Missile:Clone()
	missileToFire.Parent = workspace
	print('cloned missile to workspace')
	openDoorEvent:Fire()
	print('fired opendoor event')
end)

The script meant to fire the event

local cellDoorScript = require(game.ServerScriptService.VLSDoorScript)

local openEvent = game.ReplicatedStorage.openEvent

local launchEvent = game.Workspace:WaitForChild("Missile").ColdLaunchEvent

local rightRodHinge = script.Parent.RightDoor.PrimaryPart

local leftRodHinge = script.Parent.LeftDoor.PrimaryPart


openEvent.Event:Connect(function()
	print('opendoor event received')
	cellDoorScript.OpenVLSCellLeft(leftRodHinge)
	cellDoorScript.OpenVLSCellRight(rightRodHinge)
	wait(3)
	print('tweens completed')
	launchEvent:Fire()
	print('fired launchevent')
end)


launchEvent.Event:Connect(function()
	cellDoorScript.CloseVLSCellLeft(leftRodHinge)
	cellDoorScript.CloseVLSCellRight(rightRodHinge)
end)

The script meant to receive said event

Can I know what output you’re expecting to print the first time?

The prints should follow the order of:
‘Variables set’
‘cloned missile to workspace’
‘fired opendoor event’
‘opendoor event received’
‘tweens completed’
‘fired launchevent’

Actually, nevermind. I have fixed the issue myself. I just needed to further tweak the scripts.