Bindable Event Not Fired/Heard

Recently, I came upon few articles about a scripting concept called Object Oriented Programming. This topic, although daunting, was actually pretty easy to learn. After making a few object classes and tinkering with them I settled on making a small cube system. This was then when I encountered a huge issue with the code; unlike other issues, this one would complicate the project if not dealt with. One of the bindable events wasn’t working, this event was linked to the custom event and was mainly why I started this.

--CubeModule, ReplicatedStorage

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = BindableEvent
local Cube = {}
Cube.ClassName = "Cube"
Cube.__index = Cube

function Cube.new()
	--Set Events
	local HeldEvent = Instance.new("BindableEvent")
	
	local newCube = {
		Held = HeldEvent.Event
	}
	setmetatable(newCube,Cube)
	
	--Fire Events
	Event.Event:Connect(function(holder)
		HeldEvent:Fire(holder)
	end)
	
	return newCube
end

return Cube
--TestScript, ServerScriptService
local cube = require(CubeModule)

local new = cube.new()

Event.Held:Fire("Testplayer123")

new.Held:Connect(function(holder)
	print(holder) --prints TestPlayer12
end)

If anybody is willing to, please help with the bindable event.

Have you tried this?

new.Held:Connect(function(holder)
	print(holder)
end)

-- flip it around
game.ReplicatedStorage.Events.CubeEvents.Held:Fire("Testplayer123")

Can’t believe I haven’t thought of this. Thanks.

Event is not a property of BindableEvent


also cubeEvents is not defined anywhere

That’s how bindable events listen.

It is: BindableEvent | Roblox Creator Documentation

Sorry for making the code hard to read, everything has been solved and I will continue with the project.

1 Like

Okay, do you mind posting the fixed code? I’ve never used bindable events and I want to see what you did.

Everything was fine, I just needed to switch two lines. If you’d like to read about bindable events, visit this page: BindableEvent | Roblox Creator Documentation.