Weird Bind Action behaviour

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Ans: Trying to make it so the “gun doesnt fire everytime it is Unequipped or Equipped”
  2. What is the issue? Include screenshots / videos if possible!
    Ans:It fires when the gun is Unequipped and Equipped
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Ans: Nothing I’m confused I read the documentation
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local ContextActionService = game:GetService("ContextActionService")

	local IsEquiped = false

	-------------------------------------------
	local Gun = script.Parent

	local FireRemote = Gun:WaitForChild("FireGunRemoteEvent")

	local GunConfig = require(Gun.GunConfig)
	-------------------------------------------
	local function Fire()
		print("Fired Gun...")
	end

	Gun.Equipped:Connect(function()
		ContextActionService:BindAction("Fire_Gun",Fire,true,Enum.UserInputType.MouseButton1,Enum.UserInputType.Touch)
		print("Equipped")
	end)

	Gun.Unequipped:Connect(function()
		ContextActionService:UnbindAction("Fire_Gun")	
		print("Unequipped")
	end)
1 Like

Ignore the top part some glitchy thing

1 Like

When you use ContextActionService the function ran gets 3 arguments as followed:

  • Action Name, the name of the action.
  • Input State, whether the input began or ended.
  • Input Object, what the input was.

You can utilize these properties to prevent it from false firing.

Yeah that’s unignoreable.

1 Like

let me change that
bruh didnt mean to add that

1 Like

Keyboard Spam Trust me not intentional

It definitely looks intentional. Just in case, remove that line or roblox mods will think of it as intentional.

very much apreciated thank you so much :+1: :heart:

So it worked? If so, please mark it as a solution so people know!