tool.Activated not working if auto equipped

  1. What do you want to achieve? Keep it simple and clear!
    So, because i’m making a custom char for player, i’m cloning his tools(sword here actually) in char for it to auto equip(backpack is disabled in core gui). But tool does not give any callback from tool.Activated until i unequip sword and equip sword.
  2. What is the issue? Include screenshots / videos if possible!
    Here is video:
    https://youtu.be/jFNSVoBfJjw
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I’ve tryed using Humanoid:EquipTool instead of just cloning, but it didn’t give any results.

Sword code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerService = game:GetService("Players")

local AnimationHandler = ReplicatedStorage.Events.AnimationHandler
local ToggleSword = ReplicatedStorage.Events.ToggleSword

local tool = script.Parent

local _equipped = false

ToggleSword.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local animationToggle = {
		["false"] = "rbxassetid://71642231823937",
		["true"] = "rbxassetid://100353808017207"
	}
	SwordAnimation(char, tool, animationToggle[tostring(_equipped)])
	_equipped = not _equipped
end)

function SwordAnimation(char, sword, animationID)
	local Humanoid = char.Humanoid
	local animator = Humanoid:FindFirstChild('Animator') or Instance.new('Animator')

	animator.Parent = Humanoid
	local Animation = Instance.new("Animation")

	Animation.AnimationId = animationID


	local AnimationTrack = animator:LoadAnimation(Animation)
	AnimationTrack:Play()

	AnimationTrack.KeyframeReached:Connect(function(keyframe)
		if keyframe == "PullOut"then
			sword.SwordHandle.Torso6D.Enabled = false
			sword.SwordHandle.Arm6D.Enabled = true
		elseif keyframe == "PullIn" then
			sword.SwordHandle.Arm6D.Enabled = false
			sword.SwordHandle.Torso6D.Enabled = true
		end
	end)
end

tool.Activated:Connect(function()
	print("111", _equipped)
	if _equipped == true then
		local char = script.Parent.Parent
		AnimationHandler:FireClient(PlayerService:GetPlayerFromCharacter(char), char, nil, "rbxassetid://132152505794328")
	end
end) 

How are you auto-equipping it?

local PlayerService = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local SetPlayerCamera = ReplicatedStorage.Events.SetPlayerCamera

local PlayerTemplate = ServerStorage.PlayerTemplate
local Sword = ServerStorage.Swords["[0] wooden_sword"]

local StarterCharacter = ServerStorage.StarterCharacter

local Server = {}

function Server:ReviveCharacter(plr)
	plr.Character = nil
	local Appearance = PlayerService:GetHumanoidDescriptionFromUserId(plr.UserId)
	local PlayerChar = PlayerTemplate:Clone()
	PlayerChar.Parent = workspace
	PlayerChar.Humanoid:ApplyDescription(Appearance)
	PlayerChar.Name = plr.Name

	for _,charMesh in pairs(PlayerChar:GetChildren()) do
		if charMesh:IsA("CharacterMesh") then
			charMesh:Destroy()
		end
	end
	
	local swordClone = Sword:Clone()
	swordClone.SwordHandle.Torso6D.Part0 = PlayerChar.Torso
	swordClone.SwordHandle.Arm6D.Part0 = PlayerChar["Right Arm"]
	PlayerChar.Humanoid:EquipTool(swordClone)
	
	for _,v in StarterCharacter:GetChildren() do v:Clone().Parent = PlayerChar end
	
	SetPlayerCamera:FireClient(plr)
	
	plr.Character = PlayerChar
	
end

return Server

Not sure what’s happening, can you try equipping the tool after you clone all children of StarterCharacter?

Ok i actually just found fix. Tool won’t be considered as tool before i set Player.Character to that model. So after moving tool cloning lines after character is assigned to player it works.