-
What do you want to achieve? Keep it simple and clear!
A sword that can do animations -
What is the issue? Include screenshots / videos if possible!
My code is supposedly written the correct way, but I cant index an humanoid. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
None were there
Local script
local Character = game:GetService("Players").LocalPlayer.Character
local Tool = script.Parent
local LSHOLDANIM = Tool:WaitForChild("LSHOLD")
local LSSwing1 = Tool:WaitForChild("LSSwing1")
local Equipped = false
local Debounce = false
-- Load anims
local Swing1 = Character.Humanoid:LoadAnimation(LSSwing1)
local LSHold = Character.Humanoid:LoadAnimation(LSHOLDANIM)
-- Tool equipped
Tool.Equipped:Connect(function()
Equipped = true
LSHold:Play()
end)
Tool.Unequipped:Connect(function()
Equipped = false
LSHold:Stop()
end)
Tool.Activated:Connect(function()
if Debounce == false and Equipped then
Debounce = true
Swing1:Play()
end
end)
Error Message: " Players.justin2710.Backpack.LongSword.LocalScript:10: attempt to index nil with ‘Humanoid’ "