Weird problem with opening GUI

local playerlist = game.Players.LocalPlayer:WaitForChild('PlayerGui'):WaitForChild('PartyGUIS'):WaitForChild('PlayerList')
print('help')

--[[script.Parent.MouseButton1Down:Connect(function()
	print('WHAT THE ACTUAL')
	if playerlist.Visible == true then
		playerlist.Visible = false
	else
		playerlist.Visible = true
	end
end)]]

function open ()
	if playerlist.Visible == true then
		playerlist.Visible = false
	else
		print('SAFSDFSAFDFDAFAFD')
		playerlist.Visible = true
	end
end

script.Parent.MouseButton1Click:Connect(open)

In a local script. HOW in the world does this not work? It works in studio, but not in-game.

3 Likes

Do you have a place file? (.rbxl)

There are no exception details, and there is an effort at debugging but you never stated if the prints actually worked.

A simple thing you can do for coding something like this:

function open ()
	if playerlist.Visible == true then
		playerlist.Visible = false
	else
		print('SAFSDFSAFDFDAFAFD')
		playerlist.Visible = true
	end
end

could be like so:

function open()
    playerlist.Visible = not playerlist.Visible
end

try not to use if statements for things that could be much more simple. Also could you provide more info on the GUI, is it the actual pre-made Playerlist every game has on roblox or is it just a GUI you made?

The exception is, as I stated, in studio test mode. The prints do not work at all in-game.

It is a GUI I made. Thanks for the if advice!

You never stated that it wasn’t printing anywhere. You asked how does the script not work, you need to be more specific in your post so we can get a sense of what you need help with immediately :slight_smile: . Have you tried printing before the if statement in the function? To see if the script is reaching the function 100% of the time?

I didn’t say I stated if I printed. I said I stated the exception. I tried it and nothing prints still.

Ahhhh okay. Does “Help” print in the beginning of the script?

Nope! That’s why I find it so weird. It print it studio testing though!

Alright, so there is probably a problem with this variable then. The script is most likely infinitely waiting for the child “PlayerList”. That’s my theory at least. I THINK this can happen if “PlayerList” loaded in before the script even began waiting for it but I don’t exactly know what causes this issue fully.

local playerlist = game.Players.LocalPlayer:WaitForChild('PlayerGui'):WaitForChild('PartyGUIS'):WaitForChild('PlayerList')

That’s not what I meant by exception. An exception is a runtime error.


Anyways, have you tried using the Activated event? This is what I use over MouseButton1Click and it implies it works for all input types. The latter might work too but it makes the implication that it only fires on mouse clicks.

Also another reason to use Activated

By the way you should avoid long method call chains and you could definitely shorten that chain if you used variables.

Hm, I only added the waits cause it was happening when I just did it normally.

Still nothing prints, even after using the activated

For testing purposes try placing The print('help') before the all of the WaitForChilds, publish the place and then open the Developer Console , and see if anything prints.

I don’t think so. I did it normally without waits and still nothing…

Nothing prints in the developer console( not the studio debugger)?

If not that’s weird, are you sure that the game was published, when trying it in game?

Also if I may ask where is the local script?

Nothing prints in Dev Console (F9 in-game). Yes I have clicked published more than 10 times over the course of the last few hours heehee. The local script is inside a button.

This looks like a team create publishing issue. Are you using team create by any chance?

I turned on team create so that it auto saves, but nobody is actually in the “team”. So, any fixes? I actually manually publish it too.