I know you can do a simple disconnect, but I want the bindable event to disconnect when something happens over at another script. Also, for some reason disconnecting doesn't work. The script that's fired from the bindable event is a script that makes your character face your mouse. I will put a comment on where I want the bindable event to stop firing. Both are local by the way.

    INPUT_CONNECTION = UIS.InputBegan:Connect(function(Input, IsTyping)
        if not IsTyping then
            if not debounce then
                if Input.KeyCode == Enum.KeyCode.Z then
					debounce = true
                    game.ReplicatedStorage.FruitRemotes.GomuGomu.Pistol:FireServer(mouse.Hit, script.Parent)
					game.ReplicatedStorage.MouseFacing:Fire()
					gumPistol = UIS.InputEnded:Connect(function(Input, IsTyping)
						if not IsTyping then
							if Input.KeyCode == Enum.KeyCode.Z then
								--this is where I want it to stop firing
								game.ReplicatedStorage.FruitRemotes.GomuGomu.PistolAttack:FireServer(mouse.Hit, script.Parent)
								gumPistol:Disconnect()
							end
						end
					end)
					wait(.1)
					debounce = false
					
                end   
            end
        end
    end)

Other script

local conn
conn = game.ReplicatedStorage.MouseFacing.Event:Connect(function()
	local player = game.Players.LocalPlayer
	local character = player.Character
	if not character or not character.Parent then
    	character = player.CharacterAdded:wait()
		local tor = character:WaitForChild("HumanoidRootPart")
		local hum = character:WaitForChild("Humanoid")
	end
	local cam = game.Workspace.CurrentCamera
	local equipped = false
	local tor = character.HumanoidRootPart
	local hum = character.Humanoid
	player.CharacterAdded:Connect(function()
		character = player.Character
		tor = character:WaitForChild("HumanoidRootPart")
		hum = character:WaitForChild("Humanoid")
	end)
	local Mouse = player:GetMouse()
	local prev_mousehit

	game:GetService("RunService").RenderStepped:Connect(function()
		if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
			hum.AutoRotate = false
			if Mouse.Hit.p ~= prev_mousehit then
				tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,tor.Position.y,Mouse.Hit.p.z))
				prev_mousehit = Mouse.Hit.p
			end
		else
			hum.AutoRotate = true
		end
	end)
end)

2 comments

0

Try disabling the script.

0

Rip, it didn't work. For some reason the script still works even if you disable or disconnect.