Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to create a personal GUI that only shows up for certain ranks of a group upon entering the game?

I'm trying to create a raiding system for war clans which includes a GUI with a few buttons which control the raid (i.e. making the raid official, voiding the raid). However, I need this GUI to only appear and be usable by HRs of a certain rank. This is my first time scripting something, so, as such, my lack of experience limits me from accomplishing my goal. The GUI itself is all done and scripted, but my only problem is having it only show up for certain players.

game.Players.PlayerAdded:connect(function(Player)
	if Player:GetRankInGroup(2565156) == 255 then
		script.Parent.ControlButton.Visible = true
		script.Parent.ControlButton.Selectable = true
		script.Parent.ControlButton.Active = true
	else
		script.Parent.ControlButton.Visible = false
		script.Parent.ControlButton.Selectable = false
		script.Parent.ControlButton.Active = false
	end
end)

This is the script I created hoping it would work. I failed to realize that this would either make the GUI visible or invisible if an HR or non-group member or non-HR joined, respectively. I thought perhaps making the script a LocalScript would work since the GUI is in StarterGUI, but it didn't. I can't think of anything that would make the script only appear for certain players.

2 answers

This task can be done in many ways, here are some suggestions

Example 1, cloning it You can make a server script that uses the PlayerAdded event, and checks if their in the group, if yes clone the gui from X storage (Could be ServerStorage because this would be serverscript) or what ever. (with Archivable set to

Example 2, deleting it from script You can put this gui in StarterGui and place a localscript, and check if they are in the group (take in consideration that I have never tried this function, so I do not know if it can only in a certain script (local or server script) so use remotes if you have to I guess.) if yes than leave the gui intact, if no destroy the gui from the playergui or script.Parent (depending on the tree).

These examples are just few of many, adventure through it I guess

Sorry for the typo, Im in real hours right now

Example 1 example (:3)

You could have a server script like



--I have my doubts about this, I have not actually tested this, it is an example 

--This is a serverscript 
local storage = game:GetService("ServerStorage")
 local players = game:GetService("Players")

players.PlayerAdded:connect(function(player) 
	if (player:GetRankInGroup(2565156) == 255) then 
		local pgui = player:WaitForChild("PlayerGui") 
		local cgui = storage:FindFirstChild("GuiToClone"):Clone() 
		if (not cgui) then return end 
		cgui.Name = string.format("%s's %s", player.Name, cgui.Name) 
		cgui.Parent = pgui 
	end 
end) 

4 comments

0

If you need more help, teamcreate with me maybe

0

If I wanted to use the concept in the first example, how would I do that? Sorry, I'm really new to scripting and have little to no experience. If the script was cloned from a storage, wouldn't it still show up for all players in the game? That's my problem, I need the GUI to only show up for certain players in the group, but right now it's either all players or no players.

0

idk why, but the formatting for the code block is not working, the code is just an example, and probably not the best

0

Put the code block in between the tildes (~), not on the same line

Use could use a remote event and then fire client for each individual and check if they are in the group or not. If you need an example i could add some code and show you the basic concept. Cheers.

This discussion is preserved as it was. New answers, comments, and votes are closed.