How do I make my GUI open

Hello.
I am creating a simulator game with some people. I have a menu that will appear if a user is in a specific group.
How do I script it so that the menu appears if the user is in the group and if its not its destroys itself so that it cant be accessed by exploiters.

I can tell you , here is a script :

local player = game.Players.LocalPlayer -- adding the local player to a var
local GroupId = "" -- group id here

if player:IsInGroup(GroupId) then-- IsInGroup checks if the player is in the group, you put the group id

-- Here is your code...

else

-- if player is not in group...

end
1 Like

Like this? Also how do I make it so that is destroys the menu? or have I done it right?

local player = game.Players.LocalPlayer -- adding the local player to a var
local GroupId = "7581138" -- group id here

if player:IsInGroup(GroupId) then-- IsInGroup checks if the player is in the group, you put the group id

	game.StarterGui.StarMenuMessage.visible = true

else

	game.StarterGui.StarMenuMessage.visible = false
	destroy()

end
local player = game.Players.LocalPlayer -- adding the local player to a var
local GroupId = "7581138" -- group id here

if player:IsInGroup(GroupId) then-- IsInGroup checks if the player is in the group, you put the group id

	game.StarterGui.StarMenuMessage.visible = true

else

	game.StarterGui.StarMenuMessage.visible = false
	

end
13:56:40.625  ServerScriptService.StarMenu:4: attempt to index nil with 'IsInGroup'  -  Server - StarMenu:4

You are using a server script. You are supposed to be using a LocalScript.

2 Likes

Insert a LocalScript | Documentation - Roblox Creator Hub into your GUI. Change “script.Parent.Frame” to your Frame path.

local player = game.Players.LocalPlayer 
local GroupId = 1234567 -- GroupId here

if player:IsInGroup(GroupId) then
	script.Parent.Frame.Visible = true
else
	script.Parent.Frame.Visible = false
end
2 Likes

If you want to destroy it, then use the :Destroy() function.

 local player = game.Players.LocalPlayer 
local GroupId = 9155313

if player:IsInGroup(GroupId) then

	script.Parent.Enabled = true
else

	script.Parent:Destroy()
	
end
1 Like

Ok it works now. How do I make it destroy the menu if the user isn’t in the group?

It’s in the post above

 local player = game.Players.LocalPlayer 
local GroupId = 9155313

if player:IsInGroup(GroupId) then

	script.Parent.Enabled = true
else

	script.Parent:Destroy()
	
end
else
	script.Parent:Destroy()
end
local player = game.Players.LocalPlayer 
local GroupId = 1234567 -- GroupId here

if player:IsInGroup(GroupId) then
	script.Parent.Frame.Visible = true
else
	script.Parent:Destroy()
end