Gui not enabling

Hi, Im trying to make a click detector enable a gui but it doesnt show! The properties say that the gui is enabled. Im not getting any errors either.

Below is the script (The whole script only allows certain people to click on the button as expected)

local AllowedPlayers = {,} -- PlayerIDs
local enabled = false

script.Parent.MouseClick:Connect(function(Player)
	local FoundInTable = false
	for _, userid in pairs(AllowedPlayers) do
		if Player.UserId == userid and FoundInTable == false then
			FoundInTable = true
		end
	end
	if FoundInTable == true then
		enabled = not enabled
		game.Players.LocalPlayer.NotesGUI.Enabled = enabled
		print("Allowed")
		print(enabled)
	else
		print("Access Denied")
	end
end)

Thanks in advance if anyone can help me.
Tangy

What type of script is this and where is it located?

1 Like

Its a regular script and it is located in a click detector in workspace

Why are you usign game.Players.LocalPlayer in a regular script? use Player, LocalPlayer only works in localscripts, you alreayd got the player who clicked

1 Like

I can highly tell that this is not a server script.

1 Like

Regular scripts are not able to enable guis. Use a local script.

1 Like

This is possible. It just that you need to adjust the GUI settings for the player.

1 Like

Oops, this was a mistake from a variation I tried of the script, that line was not in the original script and it didnt work then either

Try this out perhaps?

local AllowedPlayers = {,} -- PlayerIDs
local enabled = false

script.Parent.MouseClick:Connect(function(Player)
	for _, userid in pairs(AllowedPlayers) do
		if Player.UserId == userid then
			enabled = not enabled
			Player.PlayerGui.NotesGUI.Enabled = enabled
			print("Allowed")
			print(enabled)
			break
		end
	end
end)

It’s a simpler way of going about what you want

1 Like

Just clone the GUI to the PlayerGui, and make sure the enables be property is trueZ

1 Like