Adornee value being nil

Hello!

I have been trying to set a variable using GUI Adornee’s Parent. (SurfaceGui.Adornee.Parent). The Adornee is set in the GUI, it refers to a part in Workspace. Though, the script after it wont work and F9 prints that its value is "nil", even though that the value obviously shouldn’t be nil.

I don’t know how to fix this issue, neither could find any help anywhere.

What does it say if you just print out

SurfaceGui.Adornee

Does it show the part it’s adorned to?

1 Like

When I tried printing it to F9, it just said “nil”.

I misread your post, I thought you were saying that SurfaceGui.Adornee.Parent was nil.
The probably means somewhere along the line the Adornee is getting set back to nil.

This is the whole code. (For context, it’s basically a TextBox that enables a ProximityPrompt, if you enter the correct Text)

local PASSWORD = "32$EKIRTS!312"
local SurfaceGUI = script.Parent.Parent.Parent
warn("SurfaceGUI.Adornee value")
print(SurfaceGUI.Adornee)
warn("SurfaceGUI.Adornee.Parent value")
print(SurfaceGUI.Adornee.Parent)
warn("SurfaceGUI.Adornee.Parent.Parent.Parent value")
print(SurfaceGUI.Adornee.Parent.Parent.Parent)
local HackingTables = SurfaceGUI.Adornee.Parent.Parent.Parent
local InsideMonitor = HackingTables:WaitForChild("HackingTableInside")
local Core = InsideMonitor:WaitForChild("Core")
local ProximityPrompt = Core:WaitForChild("ProximityPrompt")

warn("BEFORE TEXTBOX")
local TextBox = script.Parent

warn("BEFORE FOCUS LOST")
TextBox.FocusLost:Connect(function(enterPressed)
	warn("FOCUS LOST")
	if enterPressed then
		local Text = TextBox.Text
		if Text == PASSWORD then
			print("CORRECT PASSWORD")
			ProximityPrompt.Enabled = true
		else
			print("WRONG PASSWORD")
		end
	end
end)

If I’m right, only the warn("SurfaceGUI.Adornee value") and print(SurfaceGUI.Adornee) get printed. The print function returns nil, as mentioned already. (I used the warn function as a comment in F9, basically.)

Is the SurfaceGui in StarterGui or in the part that it’s adorned to? (Just curious if it’s just getting unset by something on the Roblox side and needs to be set again after the game loads.)

1 Like

The SurfaceGui is in StarterGui service. The Adornee is located in Workspace, though.

The location of the adornee doesn’t matter if the adornee is set

Yeah, I know. I still don’t know what is causing this issue tho, as the Adornee is indeed set. Do you know how I could fix it?

Inside the SurfaceGui add this code:

script.Parent:GetPropertyChangedSignal("Adornee"):Connect(print)

Let me know the output.

1 Like

It doesn’t print anything.

characters

Hey!

So, I managed to fix this by myself, somehow. Thanks to everybody that tried to help me, though.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.