Hey! I’m making a rank tag and I can’t seem to get my code for copying the overhead gui for each player to work; I’m not sure what I’m doing wrong; I’ve written most of the code in a noobish manner, but I need some thoughts as to why it’s not working; thanks!
This is my code:
local human = script.Parent
-- makes the overhead for players above rank 0 (guest)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player:GetRankInGroup(11108703) > 0 then
local GuiClone = script.Overhead:Clone()
local InformationLabel = GuiClone.Frame
local PlayerRank = Player:GetRoleInGroup(11108703)
GuiClone.Parent = human:FindFirstChild("Head")
InformationLabel.Rank = PlayerRank
InformationLabel.Username = human.Name
InformationLabel.Team = Player.Team.Name
end
end)
end)
-- makes the overhead for guests (rank 0)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player:GetRankInGroup() == 0 then
local GuiClone = script.Overhead:Clone()
local InformationLabel = GuiClone.Frame
local PlayerRank = Player:GetRoleInGroup(11108703)
GuiClone.Parent = human:FindFirstChild("Head")
InformationLabel.Rank:Destroy() -- destroys the rank text; if Player:GetRankInGroup() == 0
InformationLabel.Username = human.Name
InformationLabel.Team = Player.Team.Name
end
end)
end)
In case you need the game file to look deeper;
RankTag.rbxl (27.1 KB)
2 Likes
Are there any errors, can you please provide us more information?
Are you even checking if the player that joins is in the group
No there’s no errors or output
I think I have?
Player.CharacterAdded:Connect(function(Character)
if Player:GetRankInGroup(11108703) > 0 then
Try putting the script in "ServerScriptService"
, then copy and paste the code listed below, I had to recode A LOT!
local GroupID = 11108703
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
warn("Character Was Added")
local roleID = Player:GetRankInGroup(GroupID)
local PlayerRank = Player:GetRoleInGroup(GroupID)
--// GUI OBJECTS
local GuiClone = script.Overhead:Clone();
local InformationLabel = GuiClone.Frame
local playerHead = Character:WaitForChild("Head") -- waits for the player's head
if roleID > 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank.Text = PlayerRank
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
elseif roleID < 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank:Destroy() -- destroys the rank text; if Player:GetRankInGroup() == 0
InformationLabel.Team.Text = Player.Team.Name
InformationLabel.Username.Text = Player.Name
end
end)
end)
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/4/8/2/482e8cd8ffbb93c58833a757873df5a015603f44.jpeg)
1 Like
Haha thanks, still working on my scripting, I’ll try it out.
I didn’t get to see the reply before you removed it, is it working correctly or is there an issue with the code?
There was some problems with yours but I fixed them and made it work, yours only worked if the player was in the group, if they weren’t the overhead wouldn’t appear. I edited it to this;
local GroupID = 6870439
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
warn("Character Was Added")
local roleID = Player:GetRankInGroup(GroupID)
local PlayerRank = Player:GetRoleInGroup(GroupID)
--// GUI OBJECTS
local GuiClone = script.Overhead:Clone();
local InformationLabel = GuiClone.Frame
local playerHead = Character:WaitForChild("Head") -- waits for the player's head
if roleID > 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank.Text = PlayerRank
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
elseif roleID <= 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank:Destroy() -- destroys the rank text; if Player:GetRankInGroup() == 0
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
end
end)
end)
You just had to change the value of “GroupID”, sorry I forgot to change that! Besides that, it’s working correctly right?
No the group wasn’t the issue, I changed this;
if roleID > 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank.Text = PlayerRank
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
elseif roleID < 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank:Destroy() -- destroys the rank text; if Player:GetRankInGroup() == 0
InformationLabel.Team.Text = Player.Team.Name
InformationLabel.Username.Text = Player.Name
end
To this;
if roleID > 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank.Text = PlayerRank
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
elseif roleID <= 0 then
GuiClone.Parent = playerHead
InformationLabel.Rank:Destroy() -- destroys the rank text; if Player:GetRankInGroup() == 0
InformationLabel.Username.Text = Player.Name
if Player.Team ~= nil then
InformationLabel.Team.Text = Player.Team.Name -- Prevents Error..
else
InformationLabel.Team.Text = "NO TEAM"
end
end
So just some very small changes, but you helped me tremendously.
Oh yeah, completely forgot about that part of the script. I guess that’s what happens when you copy and paste code that you didn’t write ![:face_with_raised_eyebrow: :face_with_raised_eyebrow:](https://doy2mn9upadnk.cloudfront.net/images/emoji/twitter/face_with_raised_eyebrow.png?v=12)
2 Likes