Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need help! " attempt to index upvalue 'humanoid' (a nil value) " How do I fix?

Asked by 5 years ago
Edited 5 years ago

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.

0
you can use numeric for loops to shorten your code alot theking48989987 2147 — 5y
0
you should use :WaitForChild("Humanoid") instead, unless you want to redeclare the humanoid variable if it is nil theking48989987 2147 — 5y
0
Omg I was about to say that ^ greatneil80 2647 — 5y
0
Um, It didn't work. local animTrack = humanoid:WaitForChild("Humanoid"):LoadAnimation(animation). Did I do that right?. Timbawolf1 6 — 5y
View all comments (2 more)
0
You could have used many variables to keep this code much shorter and easier to read. Synth_o 136 — 5y
0
Please I need help with this. Timbawolf1 6 — 5y

Answer this question