Hi! I'm trying to make an animation script for my sword, so that it may have two slash animations, I get the error in the title when I load the game, can anyone help?
By the way, I'm using a LocalScript.
game.Players.PlayerAdded:connect(function(player) humanoid = player.Character:WaitForChild("Humanoid") end) wait(5) local slashType = false slashA = humanoid:LoadAnimation(script.Parent.Slash) slashB = humanoid:LoadAnimation(script.Parent.SlashB) if slashType == false then script.Parent.Activated:connect(function() slashA:Play() slashType = true end) end if slashType == true then slashB:Play() slashType = false end script.Parent.Unequipped:connect(function() slashA:Stop() slashB:Stop() end)
In lines 08 and 09, humanoid doesn't exist as it's contained in its own block in line 1. Also, since this is a local script you can simply wait for the humanoid of the local player (hint: local scripts don't run unless they're in the player or character).
Edit: Try waiting for the player to load before you find the character.
wait(5) -- the wait(5) is just an example, you can just wait for the player.CharacterAdded event and nest all of your functions in it. local humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid") -- rest of the code