Remote Event is acting unusual?

I’m trying to make a door using proximity prompt. My issue is the door will not close. The door uses RemoteEvents to work because tweening is smoother on the client.

local open = false

script.Parent.Triggered:Connect(function()

-------problematic------------------------------------------------------
game.ReplicatedStorage.Door_Action:FireAllClients(open, script.Parent)
------------------------------------------------------------------------
	
	if open == false then
		print("opening")
		open = true
		script.Parent.Enabled = false
		
-- won't run unless remoteEvent line is removed ---------------------------
	elseif open == true then
		print("closing")
		open = false
		script.Parent.Enabled = false
	end
---------------------------------------------------------------------------

	wait(2)
	script.Parent.Enabled = true
	
end)

The elseif statement will not run when I trigger the prompt a second time. It only seems to run the elseif statement when I remove the FireAllClients line.

I tried looking for someone with a similar problem to no avail. Does anyone know why this is happening??

1 Like

I truly don’t see a reason for why that wouldn’t work, but I suspect it may be some sort of weird behavior with the conditionals, see if this rearrangement helps you out:

local open = false
local door_event = game.ReplicatedStorage:WaitForChild('Door_Action')

script.Parent.Triggered:Connect(function()
	script.Parent.Enabled = false
	door_event:FireAllClients(open, script.Parent)
	
	if open then print("closing") else print("open") end
	
	open = not open
	task.wait(2)
	script.Parent.Enabled = true
end)
1 Like

Thanks for the suggestion, unfortunately it didn’t change anything. No errors, same problem.

script.Parent.Enabled = false

In both cases you’re setting the script’s parent’s ‘Enabled’ property to ‘false’.