How to detect if ScreenGui == nil

Bro, Can you share video of running new code just like you did previously?

1 Like

I think I figured it out, I’m deleting the object through a local script.
Could that be the problem?

1 Like

let my try delete this for server script

1 Like
local FoundCheck
repeat
task.wait(1)
FoundCheck = Player.PlayerGui:FindFirstChild("NewItemHolder)
until not FoundCheck
1 Like

And on what side is that module script running? Get by RunService:IsServer(), if it returns true, then it is On server, then yeah that’s the problem, if not then problem is something else.

1 Like

Thats my code that you added a variable to :expressionless:

1 Like

I havent even checked what you written

1 Like

I think I know why, your adding “NewItemHolder” on a local script I believe and the server cannot see it.

1 Like

I realized the problem, I delete the gui in the local script, and I need to delete the script in the server script after clicking the button.
How do I do it?

1 Like

Use remote event, on local script fire it and on server script, listen to it, check who fired it and then delete that gui from players GUI folder.

1 Like

Place in StarterGUI:

script.Parent.ChildRemoved(function(child)
	if child.Name == "SCREENGUI_NAME_HERE" then
		-- code here
	end
end)

Explanation:
Script’s ChildRemoved event fires when a child of StarterGui is removed, or in your case, turns into “nil”.

I did it, yay :)))
tysm all who helped me, guys.

That’s one way too, but I think I’ve already fixed my problem.
Thanks for your help too!

1 Like