- 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. - What is the issue? Include screenshots / videos if possible!
Here is video:
https://youtu.be/jFNSVoBfJjw - 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)