local Player = game.Players.LocalPlayer
repeat wait() until Player.Character -- just waits till the character spawns to get the animations
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Animation = Humanoid:LoadAnimation(script.Animation)
local IdleTrack
local EquipUnequipTrack
local Idle = Instance.new("Animation")
local EquipUnequip = Instance.new("Animation")
Idle.AnimationId = "http://www.roblox.com/Asset?ID=11890425986"
EquipUnequip.AnimationId = "http://www.roblox.com/Asset?ID=11906096433"
tool = script.Parent
tool.Equipped:Connect(function()
script.Parent.Show:FireServer()
IdleTrack = script.Parent.Parent.Humanoid:LoadAnimation(Idle)
EquipUnequipTrack = script.Parent.Parent.Humanoid:LoadAnimation(EquipUnequip)
game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = 'rbxassetid://11901386770'
EquipUnequipTrack:Play()
wait(0.05)
IdleTrack:Play()
end)
tool.Unequipped:Connect(function()
script.Parent.Hide:FireServer()
IdleTrack:Stop()
EquipUnequipTrack:Play()
game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = 'rbxassetid://180426354' --default id
end)
iam not sure if theres any issues with the script this is what happens when the tool is equipped
Maybe this is happening because you are calling Humanoid:LoadAnimation() everytime Tool.Equipped fires, and Humanoid:LoadAnimation() is deprecated. You should use the Humanoid’s Animator and call Animator:LoadAnimation() instead; create an Animator using Instance.new() if the Humanoid doesn’t have one.
Also, instead of loading the animation everytime the Tool.Equipped event fires, do you think you could just store the tracks outside of the event? For example:
local character = player.Character
local animator = character.Humanoid.Animator
local idleTrack, equipTrack
local function createTrack(id: string)
local animation = Instance.new("Animation")
animation .AnimationId = id
return animator:LoadAnimation(animation)
end
idleTrack = createTrack("http://www.roblox.com/Asset?ID=11890425986")
equipTrack = createTrack("http://www.roblox.com/Asset?ID=11906096433")
tool.Equipped:Connect(function()
equipTrack:Play()
task.wait(0.05)
idleTrack:Play()
end)
tool.Unequipped:Connect(function()
equipTrack:Stop()
idleTrack:Stop()
end)