Help with hidename command

Hi, so I’m not much of a scripter but I need a little help with this.
I know it might be really simple but I just don’t know the solution.

I have been trying to make a “Hidenames” command, where when someone over the rank of 11, if they say “.hidenames” then it will hide everyone’s names. My game uses a custom overhead Gui. It inserts a BillboardGui, which displays the rank and name.

The path of the overhead GUI is: game.Workspace.[PLAYER].Head.Rank
“Rank” is the BillboardGui

I can’t find a way to run through every player in the game and destroy the GUI, however this is what I want to achieve.

Current script:

local group = 13962134
local minrank = 11

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(Message)
		if Message == ".hidenames" then
			if player:GetRankInGroup(group) >= minrank then
				for i,v in pairs(game.Players:GetChildren()) do
					--????.Head.Rank:Destroy() *im not sure if this is the correct thing to use and confused on what to use (where the ???? is)*
				end
			end
		end
	end)
end)

So, overall what I want to know is how do I run through every player in the server, and destroy their Overhead GUI. I don’t know if the use of “for i,v” is correct, as I’m not much of a scripter. If it isn’t, please tell me the correct way. :slight_smile:

Don’t destroy it, just set Enabled to false or set visible to false.

This is actually very simple. Let me tell you the formula - To get a player’s head, you can easily do player.Character.Head. player.Character in here means the player’s character, and then you can get the player’s head with .Head after.

The pairs loop would look like this if correct:

for i,v in pairs(game.Players:GetChildren()) do
    v.Character.Head.Rank:Destroy()
end
1 Like

Alright, but how would I go through every player in the game and do that?

Alright, thank you so much. I’ll try it right now and update you. Thanks again.

Works PERFECTLY! Thanks so much. :smiley:

1 Like