Overhead Rank Gui Script

Hello, soo I’ve recently wanted to start a restaurant, and I am trying to make a Over Head Rank Gui like in the image below, but I don’t know where to start, could somebody please help me?

image

And I tried replicating the effect or searching for a tutorial similar to this, but I didn’t find any.

4 Likes

Hey there!

How I do it is that I create a BillboardGui, design it, do stuff with it to make it look how I want.
Then I put it inside ReplicatedStorage, make a quick script which checks when player joins and then puts the BillboardGui inside player’s head.

Shortly :

  1. Make BillboardGui
  2. Make script that checks when player joins and puts the BillboardGui into his head

Hope that helped!

2 Likes

I know that, but the thing is that I don’t really know how to design it that way, or how to code. I have a attempt of me designing it:

You should try making this yourself and then ask for specific help on the areas of the system you are struggling on. It is worth searching before you post because there are a few existing topics with a similar issue to yours:

https://devforum.roblox.com/search?q=Overhead%20gui


What you will need to know:

There are multiple ways this can be made and depending on your use case some are better than others. I personally like to take a module approach and have one ModuleScript placed in ReplicatedStorage that holds all the essential functions. This way the client and the server can both access the functions.

Lets start by placing a BillboardGui in a part in workspace and design the look of the gui. To get the scaling right you should use scale instead of offset in the actual BilboardGui object and both the TextLabels. I wont go into too much more detail on how to do this part because you can figure out most of this part by yourself:
Image Image

Once you have made the gui you should place one ModuleScript in ReplicatedStorage and one script in ServerScriptService and then place the Gui you created above in the ModuleScript that is in ReplicatedStorage:
Image

ModuleScript that is in ReplicatedStorage:

Lets now start filling out the ModuleScripts code that is in ReplicatedStorage. Having a module script in ReplicatedSorage allows you to run the same function on the server and the client meaning you don’t have to repeat code. Here is what the contents of the ModuleScript should look like:

local PlayersService = game:GetService("Players")
local OverheadGuiObject = script.OverheadGuiObject

local module = {}

function module:Create(Player, GroupId) -- Creates the overhead gui for the player
	local Character = Player.Character or Player.CharacterAdded:Wait() -- Gets the players character
	
	local Clone = OverheadGuiObject:Clone() -- Clones the ovehead gui to the characters head
	Clone.PlayerName.Text = Player.Name
	Clone.PlayerRank.Text = Player:GetRoleInGroup(GroupId)
	Clone.Parent = Character.Head
	
	Character.Humanoid.NameDisplayDistance = 0
end

function module:Hide(Player) -- Hides a specific players overhead gui
	local Character = Player.Character or Player.CharacterAdded:Wait()
	
	Character.Head.OverheadGuiObject.Enabled = false
end

return module

Script in ServerScriptService

Now that you have the ModuleScript setup you need to actually run the functions within it and the way you do this is by running them through a script. In the code below a function is fired when the players is added and then another function is fired when the players character is added:

local PlayersService = game:GetService("Players")
local OverheadModule = require(game:GetService("ReplicatedStorage").OverheadModule)

PlayersService.PlayerAdded:Connect(function(Player) -- Fires when the player joins the game
	Player.CharacterAdded:Connect(function(Character) -- Fires each time the players character is added
		OverheadModule:Create(Player, 3514227) -- Player, GroupId
	end)
end)

9 Likes

There is a thread that might help you:

1 Like

can you use module scripts in server scripts?

good tutorial

I am assuming this was meant to be a reply to me?

If I am understanding your question correctly you can require a ModuleScript from either a script or a LocalScript. ModuleScrips can be placed either on the client or the server or both becuse they are only a container for code. People place ModuleScrips in ReplicatedStorage because ReplicatedStorage is a shared container for the client and the server meaning you can store code there that is ran on both the client and the server.

ModuleScrips main use case is to reduce the amount of code you repeat because it is generally bad practice to copy and past the exact same function in several scrips. When coding you should try and follow the DRY(Don’t repeat yourself) principle where you can.

1 Like

everytime i attempted to use modulescripts on server scripts, nothing would happen. Although its supposed to be a container for code

If you want to continue this discussion feel free to DM me or create a new thread because this is starting to get off-topic. After this post I wont be answering anymore questions about ModuleScrips on this thread.


I will have to see your code and your hierarchy to know exactly what you are doing wrong because ModuleScrips work on the server and for server scripts. The only thing I can suggest to do is to take a look at the code below and compare it to yours and try and figure out what you are doing wrong:
Image

Server Script

local ModuleScript = require(script.ModuleScript)
ModuleScript.foo()

ModuleScript

local module = {}

function module.foo()
	print("bar")
end

return module
1 Like