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

How do I fix "...............Attempt to index nil with"...............'"?

Asked by 3 years ago
Edited 3 years ago

Hello, recently I have been trying to script a script that makes certain imagelabels appear whenever the local player's speed is changed.

NOTE: I am using discord image links because I don't know how to import images in a post..

This is the error I keep getting: https://i.gyazo.com/46c1f461d36a17300fa9dd2093c9e8cc.png

Example for what I wanted:

Whenever I am running (with walkspeed 16), then an imagelabel appears visible with a silhouette person that looks like it's running.

Another example:

If I am normally walking (with walkspeed 11), then an imagelabel appears visible with a silhouette person that looks like it's walking.

Here is a picture of my GUI setup: https://i.gyazo.com/07ea87d7e0f262ffc9e10030218a253d.png

This is the code I am using in a localscript inside of the GUI:

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

local humanoid = char:FindFirstChild("Humanoid")
while true do
    wait(1)
    if humanoid.WalkSpeed == 11 then
        script.Parent.Background.Walking.Visible = true
        script.Parent.Background.Running.Visible = false
    end

    if humanoid.WalkSpeed >= 11 then
        script.Parent.Background.Walking.Visible = false
        script.Parent.Background.Running.Visible = true
    end
    if humanoid.WalkSpeed <= 11 then
        script.Parent.Background.Walking.Visible = false
        script.Parent.Background.Running.Visible = false
    end
end

If there is any questions about my post, please reply them!

0
the images are all blocked. can you use gyazo or something? NeonPandaEyes331 21 — 3y
0
Yes. HenriVilliers 0 — 3y
0
It is edited with gyazo links now. HenriVilliers 0 — 3y

Answer this question