It says " attempt to index upvalue 'humanoid' (a nil value) " here's my code,

local Player = game.Players.LocalPlayer
local char = Player.Character
local mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local cooldown = 0
local myBool = true
local humanoid = game.Players.LocalPlayer:FindFirstChild("Humanoid")
mouse.KeyDown:connect(function(k)
	k = k:lower()
	if k == "z" then
		if myBool then
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value + .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value + .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value + .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value + .5
		wait()
		myBool = false
		else
			Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		Player.Character.Humanoid.BodyDepthScale.Value = Player.Character.Humanoid.BodyDepthScale.Value - .5
		Player.Character.Humanoid.BodyHeightScale.Value = Player.Character.Humanoid.BodyHeightScale.Value - .5
		Player.Character.Humanoid.BodyWidthScale.Value = Player.Character.Humanoid.BodyWidthScale.Value - .5
		Player.Character.Humanoid.HeadScale.Value = Player.Character.Humanoid.HeadScale.Value - .5
		wait()
		myBool = true
			
		end
	end
end)
mouse.KeyDown:connect(function(k)
	k = k:lower()
	if k == "x" then
		local animation = Instance.new("Animation")
		animation.Name = "Kick"	
		animation.AnimationId = "rbxassetid://2524044641"
		local animTrack = humanoid:LoadAnimation(animation)
		animTrack:Play()
	end
end)

It's the bottom part where im having trouble at line, 106.

6 comments

0

you can use numeric for loops to shorten your code alot

0

you should use :WaitForChild("Humanoid") instead, unless you want to redeclare the humanoid variable if it is nil

0

Omg I was about to say that ^

0

Um, It didn't work. local animTrack = humanoid:WaitForChild("Humanoid"):LoadAnimation(animation). Did I do that right?.

0

You could have used many variables to keep this code much shorter and easier to read.

0

Please I need help with this.