Custom Tool System

I am currently planning out a custom tool system. I have an idea how I want to do the client side code. I am going to use an OOP module script to give functionality for client side tools. (I can explain further if needed…) My problem is how I am going to do the networking. I thought of two ideas and wanted peoples opinions on what I should do.

1. Have another OOP module script on the server and an object is created through a remote event. I would then create a RemoteEvent on the server and parent it to the custom tool so the scripts can communicate.

2. The other option is to just set up a server script that handles all tools with certain remote events. (I can once again explain further if needed.

Your opinions would be highly appreciated!

3 Likes

Here is an example of what the client OOP object could look like.

local Sword = {}
Sword.__index = Sword

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

local Engine = require(ReplicatedStorage.Engine)
local Janitor = Engine.load("Janitor")

function Sword.new()
    local self = {}
	
    self.Janitor = Janitor.new()
	
    return setmetatable(self, Sword)
end

function Sword:Enable()
    self.Janitor:GiveTask(UserInputService.InputBegan:Connect(function(input, proccessed)
	if (input.UserInputType == Enum.UserInputType.MouseButton1 and not proccessed) then
	   print('Swing sword!')
	end
    end))
end

function Sword:Disable()
    self.Janitor:Clean()
end

function Sword:Destroy()
    self:Disable()
end

return Sword
2 Likes

I’m currently creating a custom tool system as well. The best way I can think of would be to equip tools on the client and then send a request to the server to create a fake, cosmetic tool. This would take care of instant equipping and other players would see the tool. Any functions that the tool needs to run on the server can be done with remote events.

The only big issue with this method would be that the tool object on the client is different than the tool object on the server, so you have to find the tool by name instead of directly passing the object as an argument with any client-server communication.