So every time i test the game it gives me the common error - "Players.Gingerely.Backpack.Tool.LocalScript:7: attempt to index local 'humanoid' (a nil value)" and i do not understand whats actually wrong... Btw, this is in a local script.

local plr = game.Players.LocalPlayer
local chance = math.random(1,2)
local char = plr.Character or workspace.ChildAdded:Wait()
local humanoid = char:FindFirstChild("Humanoid")
local anim1 = Instance.new("Animation")
local anim2 = Instance.new("Animation")
local playanim1 = humanoid:LoadAnimation(anim1)
local playanim2 = humanoid:LoadAnimation(anim2)
local tool = script.Parent
anim2.AnimationId = "rbxassetid://4582322296"
anim1.AnimationId = "rbxassetid://4582313527"

local debounce = false

tool.Activated:Connect(function()
    if debounce == true then
        return 
end
	if chance == 1 then
	debounce = true
    if playanim1 ~= nil then 
        playanim1:Play()
        wait(1.5)
        playanim1:Stop()

if chance == 2 then
	debounce = true
    if playanim2 ~= nil then 
        playanim2:Play()
        wait(1.5)
        playanim2:Stop()
end
end
    end
	end
	end)