Hey! So, I have scripted an overhead nametag, and it works. But, it only works on one player, so if you join the game, it will work on you. But once someone new joins, it disappears off of your head and appears on the person who joins head. Can anyone spot the error and help me fix it? Here is the script.
> local royalty = {
2045300767, --hcpefuls
1189028861, -- starrysouIs
123618280, -- OLIWEGZ
1571187305 -- d4coded
}
local colors = {
Color3.fromRGB(254, 0, 0),
Color3.fromRGB(255, 127, 0),
Color3.fromRGB(255, 221, 1),
Color3.fromRGB(0, 200, 0),
Color3.fromRGB(0, 160, 199),
Color3.fromRGB(0, 55, 230),
Color3.fromRGB(129, 16, 210)
}
local rainbowinfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local groupid = 12447069
local rainbowgamepassid = 25859535
local vipgamepassid = 24818424
local MarketplaceService = game:GetService("MarketplaceService")
local TweenService = game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
local billboardui = ServerStorage:WaitForChild("NameTag"):Clone()
local username = billboardui:WaitForChild("Frame"):WaitForChild("PlayerName")
local rank = billboardui:WaitForChild("Frame"):WaitForChild("Rank")
local HRicon = billboardui:WaitForChild("Frame"):WaitForChild("Badges"):WaitForChild("HighRank")
local VIPicon = billboardui:WaitForChild("Frame"):WaitForChild("Badges"):WaitForChild("VIP")
local RPicon = billboardui:WaitForChild("Frame"):WaitForChild("Badges"):WaitForChild("RobloxPremium")
local function makeRainbow(label)
label.TextColor3 = colors[1]
local i = 1
while true do
local tween = TweenService:Create(
label,
rainbowinfo,
{TextColor3 = colors[i]}
)
tween:Play()
repeat wait() until tween.Completed
wait(0.1)
if i == #colors then i = 1 else i = i + 1 end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
username.Text = string.upper(player.Name)
rank.Text = player:GetRoleInGroup(groupid)
billboardui.Parent = workspace:WaitForChild(player.Name).Head
if player:GetRankInGroup(groupid) >= 11 then
HRicon.Visible = true
else
HRicon.Visible = false
end
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, vipgamepassid) then
VIPicon.Visible = true
else
VIPicon.Visible = false
end
if player.MembershipType == Enum.MembershipType.Premium then
RPicon.Visible = true
elseif player.MembershipType == Enum.MembershipType.None then
RPicon.Visible = false
end
if table.find(royalty, player.UserId) then
makeRainbow(username)
end
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, rainbowgamepassid) then
makeRainbow(username)
end
end)
end)