Hello,
Whenever I use BindAction to a function, the function plays and doesn't stop.
Here is the code I am using:
local function toolActivated(actionName, inputState, inputObject) currentModule = require(script[inputObject.KeyCode.Name]) currentModule.Weld(currentFoot) currentModule.TouchedEvent(currentFoot) end CAS:BindAction('Fire', toolActivated, false, mousebutton1, 'q', 'e', 'r', 't', 'y', 'f', 'g', 'h', 'z', 'x', 'c', 'v', 'b', 'n')
When I press one of the buttons that triggers the function, the "TouchedEvent" will play continuously. The touched event is basically a touched function.
(____.Parent.Touched:connect(function()) etc.)
However, the goal is that I only want to play the touched function ONCE when the bindaction is triggered.
I've tried to think about booleans and a way to unbind the action but I just cannot get my head around it.
I'm curious to find out methods to solving this that any of you may have and I appreciate any help.
local function toolActivated(actionName, inputState, inputObject) if inputState ~= Enum.UserInputState.Begin then return end currentModule = require(script[inputObject.KeyCode.Name]) currentModule.Weld(currentFoot) currentModule.TouchedEvent(currentFoot) end local Inputs = {Enum.KeyCode.Q,Enum.KeyCode.E,Enum.KeyCode.R,Enum.KeyCode.T,Enum.KeyCode.Y,Enum.KeyCode.F,Enum.KeyCode.G,Enum.KeyCode.H,Enum.KeyCode.Z,Enum.KeyCode.X,Enum.KeyCode.C,Enum.KeyCode.V,Enum.KeyCode.B,Enum.KeyCode.N, Enum.UserInputType.MouseButton1} CAS:BindAction('Fire', toolActivated, false, unpack(Inputs))