Im starting to believe that making the inputs in the components is actually a good idea, requiring the main module on the client as a matter of it being “equipped” the components will just start listening for input, to optimise this I would use parallel lua
That is a good idea, but it might be hard to code. You can look for a tool in the character and look up some info about it from storage.
default module / functionality:
local PushComp = require(script.Push)
local default = {}
default.__index = default
function default.new(Power)
local PushNew = PushComp.new(Power)
local DefHand = {}
DefHand.PushStartListen = PushNew["StartListen"]
DefHand.PushFunc = PushNew["Push"]
setmetatable(PushNew,DefHand)
setmetatable(DefHand, default)
return DefHand
end
function default:EnableAllListeners(Key1)
self.PushStartListen(Key1)
end
return default
push component:
local pushcom = {}
pushcom.__index = pushcom
function pushcom.new(power)
local self = setmetatable({}, pushcom)
self.Power = power
return self
end
function pushcom:Push()
print("e")
end
local uis = game:GetService("UserInputService")
function pushcom:StartListen(Key)
uis.InputBegan:Connect(function(input, gp)
if gp then return end
if (input.UserInputType or input.KeyCode) == Enum.UserInputType[Key or "MouseButton1"] then
pushcom:Push()
end
end)
end
return pushcom
This worked well, i guess I will stick with this and make remote events instead of just printing e
(dont mind that i didnt make an or statement for the keycode too)
1 Like