Hi, I want to make a knife but my animation doesn't load.. Why and how to fix?
This is in a ClientScript put in a Tool
--< Services
local PlayerService = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')
--< Variables
local ToolS = script
local Tool = ToolS.Parent
local Player = PlayerService.LocalPlayer
local IsEquip = false
local LastAnim = {}
--< Functions
local function FindAnimation(player)
for index, animation in pairs(Tool.Handle.Slashs:GetChildren()) do
if LastAnim[1] ~= animation then
LastAnim[1] = animation
return animation, Tool.Handle.Sounds:GetChildren()[math.random(1, #Tool.Handle.Sounds:GetChildren())]
end
end
end
--< Events
Tool.Equipped:Connect(function()
IsEquip = true
end)
Tool.Unequipped:Connect(function()
IsEquip = false
end)
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and IsEquip then
local Anim, Sound = FindAnimation()
if Anim then
print(Anim.Name, Sound.Name)
local AnimationTrack = Player.Character.Humanoid:LoadAnimation(Tool.Handle.Slashs[Anim.Name])
AnimationTrack:Play()
Sound:Play()
end
end
end)

2 comments
Check the output for errors. You need to own the animation to use it.
It's my own animation, and the output is empty.