When I try to run script.Parent.ScreenGui2.waiting.Text="Waiting for more players...", along with some other code, it errors out saying "ScreenGui2 is not a valid member of PlayerGui", even though it is. This code is in a localscript, and the following is the entire function containing the code.

local function clickdetection(gui)
	print(_G.notenoughplayers)
	if _G.notenoughplayers==true then
		print("not enough players")
		buttontransparency(0.5)
		script.Parent.ScreenGui2.waiting.Text="Waiting for more players..."

What makes this more confusing is that if I created a new localscript and inserted the above code, It would work. Why does it happen/How can I fix it?

4 comments

0

try to use :WaitForChild()

0

If this is a server-side script, there's your problem. Server-side scripts cannot access PlayerGui's descendants.

0

It looks like you're trying to use a regular script, that cannot mess with PlayerGui. You would have to change it over to a LocalScript, and use server remotes.

0

doing WaitForChild worked, thanks