Help with Bindable Events

Hello all, I am trying to make a door system with bindable events but can’t seem to get it to work. Both of the following scripts are in ServerScriptService.

local Switch = workspace.Part
local clickDetector = Switch.ClickDetector

clickDetector.MouseClick:Connect(function()
	game.ReplicatedStorage.BindableEvent:Fire()
	print("Clicked")
end)

It detects the click but won’t fire the event.

local doorPart = workspace.DoorPart
local opened = doorPart.Opened

local function EventHappened()
	if opened == false then
		doorPart.Transparency = 0.4
		doorPart.CanCollide = false
		opened = true
		print("Opened")
	elseif opened == true then
		doorPart.Transparency = 0
		doorPart.CanCollide = true
		opened = false
		print("Closed")
	end
end

game.ReplicatedStorage.BindableEvent.Event:Connect(EventHappened)

Thanks for help!

1 Like

doorPart.Opened should be doorPart.Opened.Value

2 Likes

this is the correct answer. i tried your script and saw that.

Replace your EventHappened function with this.

local function EventHappened()
	if opened.Value == false then
		doorPart.Transparency = 0.4
		doorPart.CanCollide = false
		opened = true
		print("Opened")
	elseif opened.Value == true then
		doorPart.Transparency = 0
		doorPart.CanCollide = true
		opened = false
		print("Closed")
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.