I made a custom hotbar for my game, and whenever you equip a tool by tapping the UI on mobile, it fires Tool.Activated. Here’s my code:
local players = game:GetService("Players");
local replicatedStorage = game:GetService("ReplicatedStorage");
local stun = replicatedStorage.Stun;
local localPlayer = players.LocalPlayer;
local gun = script.Parent;
I also tried equipping the tool on the server by firing a remote event but the result is the same. This is what I do for equipping the tool:
self._humanoid:EquipTool(tool) -- // Equip the tool
It’s probably because when you tap the screen, it equips the tool but then registers the tap as an activation. Try creating a variable named equipped, set it to true or false when the tool is equipped/unequipped and then check if equipped == true in the activated function. And you could even try adding a delay, so it sets equipped to true 0.5 second after equipping
I would just not rely on the Activated event, and whenever the tool equips I will create a temporary connection (until unequipped) for whenever there is a Tap/Click (use ContextActionService).
Make sure you don’t equip the tool whenever the tool button is held, but rather clicked, because as previously stated it may register the Activated event on release.