Tool script activating when a different tool is clicked

  1. What do you want to achieve? Keep it simple and clear!
    Have it so when I click once on a certain tool it fires an event, twice for a different one. ONLY for a specific tool.

  2. What is the issue? Include screenshots / videos if possible!
    The script is firing the events even though the specific tool that contains the script is not being clicked on.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked on the Devforum and haven’t find any cases related to mine, and google hasn’t shown me much.

The events fired brings a model out of server storage and puts it in the place of where the player who clicked the tool is along with other things. However they don’t interfere with the local script.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()


local Clicks = 0

script.Parent.Equipped:Connect(function(b)
	Mouse.Button1Down:Connect(function()

		
		animation =game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)


		
		Clicks = Clicks + 1
		if Clicks == 1 then
			animation:Play()
			game.ReplicatedStorage.Teleport1:FireServer(b)
			wait(3)
			animation:Stop()
		end

		if Clicks == 2 then
			game.ReplicatedStorage.Teleport2:FireServer(b)
			Clicks = 0
			
			end
		end)
end)

script.Parent.Unequipped:Connect(function()
animation:Stop()
	end)

1 Like

Why are you using the mouse for the button1down event? You can just use the .Activated event of the tool.

1 Like

I was originally taught that way, but I’ll see if that fixes it.

1 Like

You shouldn’t use the mouse for tool activation, the .Activated event exists. It is also good because you don’t have to put it in an Equipped event.

You should ever only really use mouse for tool activation if your tool is like ACS gun engine.

2 Likes

I see. Well, that’s good to know I suppose. I just tested it and it works, thanks.

1 Like