Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Yes it indeed worked after I used WaitForChild(). Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.