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

How can I make a function that a label appears above a players head if they're in a group?

I need to make a script so that, when a player joins, if they're in a certain group and rank, a name tag appears above their head. The label will say which group they're in and the rank that they're in. How can I do this?

6 comments

1

Do not request scripts please.

1

It's scripting helpers bro. That's what you do; ask for scripts and help

0

^ Even if someone requests, it's always a good idea to attempt to help anyways.

1

^ Even if someone requests, it's always a good idea to close the question. This isn't a place to ask for scripts it's a place to get help on scripts you already made. And don't come with some free model bs either. -1 @OP

1

Agreed.

1

I feel that scripting helpers should be for FIXING scripts, not asking for free scripts, that's like inserting a free model.

1 answer

Well to make a function like that, we first need the player.

game.Players.PlayerAdded:Connect(someFunction)

Placing this in ServerScriptService, whenever a player joins, the function "someFunction" will be fired and the player instance will be given to it.

Next we need the group ID.

local groupId = 000 -- Enter group ID here.

Now, inside our function we need to check their role in the group. We can do this as so:

local function someFunction(plr)
	local role = plr:GetRoleInGroup(groupId) -- Will be guest if they are not in the group.
end

Then, we need to create a billboard GUI for the GUI above the players head, and the textlabel displaying the info.

repeat
	wait()
until plr.Character
local gui = Instance.new("BillboardGui", plr.Character:WaitForChild("Head"))
local label = Instance.new("TextLabel", gui)
label.Text = plr.Name .. role

All done! Well, almost. There are a few problems with the code but I will leave that up to you. I have given you the bulk of what you need to know!

Apologies for any grammatical errors.

5 comments

0

-1 for using polling

0

^^ ??

0

https://en.wikipedia.org/wiki/Busy_waiting (player.CharacterAdded is an event, make the best of it.)

0

^^ I see your point, both ways work.

0

But your way isn't efficient. There is absolutely ZERO (not even zero, literally negative) reason to be polling in event-based programming like in roblox. Check this out : https://devforum.roblox.com/t/avoiding-wait-and-why/244015

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