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

Error: attempt to index upvalue 'GeigerGUI' (a nil value). Help?

Asked by
rs1n1 2
5 years ago

Hello. My first question.

So... I can't wrap my head around this...

local Player = game.Players.LocalPlayer
local GeigerGUI = Player.PlayerGui:FindFirstChild("GeigerCounter")

script.Parent.Equipped:Connect(function(Equip)
    GeigerGUI.Enabled = true
end)

script.Parent.Unequipped:Connect(function(UnEquip)
    GeigerGUI.Enabled = false
end)

Gives out the error:

23:36:05.477 - Players.rs1n1.Backpack.GeigerCounter.LocalScript:5: attempt to index upvalue 'GeigerGUI' (a nil value)

I have no idea why this happens.

This is in a local script. The GUI does exist.

LocalScripts can't detect if a tool is equipped? I remember using them for something like this not a long time ago.

Also, the files the things I'm messing with are in: https://imgur.com/a/WO3lv7L

https://imgur.com/a/a2oxEGa

Any ideas? Plz.

1 answer

Log in to vote
0
Answered by 5 years ago

It means that GeigerGUI is nil. It's a tad odd since from what I can see this is a localscript within that specific GUI so you would assume it is loaded.

Anyhow, try making FindFirstChild into WaitForChild and see if that does anything, if not then make sure you actually spelled the name of the GUI correctly. And if that isn't the case you can always reference the GUI by using .Parent on your script

0
Yes it indeed worked after I used WaitForChild(). Thank you so much! rs1n1 2 — 5y
Ad

Answer this question