Help & Feedback on a Bind Module

Hello im trying to make a game in the moment and i ran into some issues regarding on how to handle some inputs and im here today to ask for some tips on coding meanwhile requesting some feedback on my Bind Module.

any help and feedback are appreciated!

local CAS = game:GetService("ContextActionService")

local Bind = {}

Bind.__index = Bind

function Bind.new()
	local self = setmetatable({}, Bind)
	
	self.BindedActions = {}
	
	return self
end

function Bind:Bind(name, callback, key)
	if not (name and callback and key) then
		warn("Didn't recieve name/callback/key, returning...")
		return
	end
	
	self.BindedActions[name] = callback
	CAS:BindAction(name, callback, false, key)
end

function Bind:UnBind(name)
	if not (name) then
		warn("Didn't recieve an action name, returning...")
		return
	end
	
	self.BindedActions[name] = nil
	CAS:UnbindAction(name)
end

function Bind:UnBindAll()
	for BindedAct, BindedFunc in pairs(self.BindedActions) do
		self:UnBind(BindedAct)
	end
end

return Bind
1 Like

“OOP” is the least thing you want to use for that considering you aren’t even use methods properly,
You want to have array referancing every connection and that about it

Consider using new input actions