So basically, I’m working on this soccer system, and I have certain “methods” of kicking the ball for certain tools, for example, for the pass tool, you can do “high pass, low pass, backspin, etc” and the way it works is, if ur holding mousebutton1 and u press the key while charging, it knows to do that specific method of kicking the ball. But since all my other scripts are also checking for mousebutton1, the kick-power “power
” gets charged for every other script aswell.
local function onInputBegan(input, isProcessed)
if isProcessed or not expectingInput then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
isInputActivated = true
isKeyDown = false
power = 25
while isInputActivated do -- While mouse is down
if UserInputService:IsKeyDown(Enum.KeyCode.Q) then -- If they press the key
isKeyDown = true
print("Triggered")
end
power = math.min(power + 1, MAX_POWER)
print(power)
task.wait(1/60)
end
end
end
If you’re confused, here you can see in the image that when I hold my mouse down, it is charging the kicking power for multiple scripts. I’m just wondering if this is the right way to do it. Everything works, I’m just wondering if I should be doing something else to optimize it.