What is the best way to consider making an OOP tool?

Salvete viri feminaeque, I have ran into an issue or roadblock when creating my game. I want tools that use Object Oriented Programming in order to have inheritance between them. However, the tools are created on the Server-Side and inputs can only be handled on the Client. I did think of creating a remote event to send inputs to the server whenever they occurred; however, I ran into a possible issue as there would most likely needed to be other handlers for UserInputService in order to implement multi device support. Should I have a OOP server side tool system and a OOP client side tool system (E.G a control handler module that only handles specific inputs while there being another that inherits the inputs from the first and adds onto it); or are there any better options available that I currently am not thinking about? :thinking:

Here is an example of how I would go about it

ServerSideScript:

local Gear = {}
Gear.__index = Gear

function Gear:DoSomething()
      error("Why are you using this forbidden tool?!")
end

function Gear.new(tool, controlSender)
	local newGear = {}
	setmetatable(newGear, Gear)
	
	newGear.Tool = tool
	newGear.InputHandler = controlSender.Event:connect(function(inputObj)
		--call methods
            newGear:DoSomething()
	end)
	
	return newGear
end

And for the client side:

local UserInputService = game:GetService("UserInputService")

local ControlReciever = {}
ControlReciever.__index = ControlReciever

function ControlReciever.new(controlSender)
	local newControlReciever = {}
	setmetatable(newControlReciever, ControlReciever)
	
	newControlReciever.ControlHandlers = {}
	
	local controlHandler = UserInputService.InputBegan:connect(function(inputObject)
		controlSender:Fire(inputObject)
	end)
    --[[
	uses table.Insert as there might need to be multiple control handlers
    for varying device support.
    --]]
	table.insert(newControlReciever.ControlHandlers, controlHandler)
    return newControlReciever
end

return ControlReciever

Is this a good method?

1 Like

Just to note, I am not recreating a tool system; I am attempting to make a tool how they would normally be so but with object oriented programming.