This is the code that goes in a LocalScript inside of StarterCharacterScripts
for _, player in pairs(game.Players:GetPlayers()) do a = Instance.new("BillboardGui", player.Character.Head) a.Size = UDim2.new({0, 200},{0, 50}) a.LightInfluence = 0 a.MaxDistance = 50 a.StudsOffset = Vector3.new(0,1.4,0) a.Size = UDim2.new(0, 200, 0, 50) b = Instance.new("TextLabel", a) b.BackgroundTransparency = 1 b.BorderSizePixel = 0 b.Font = "Legacy" b.TextColor3 = Color3.new(255,255,255) b.TextSize = 10 b.TextStrokeTransparency = 0 b.TextYAlignment = "Top" b.Text = player.Name b.Size = UDim2.new(0, 200, 0, 50) end for _, player in pairs(game.Players:GetPlayers()) do if player.UserId == 391034812 then b.Text = "†shovah†" b.Font = "Bodoni" b.TextSize = 20 end end for _, player in pairs(game.Players:GetPlayers()) do if player.UserId == 76808471 then b.Text = "†orua†" end end for _, player in pairs(game.Players:GetPlayers()) do if player.UserId == 14731493 then b.Text = "†ethan†" end end
When I use this, it gives the rank to random players, instead of the developers, how do I fix this?
PlayerAdded
event. This will allow us to check if a player is an admin without looping.local admins = { -- table of admins. place user ids here [game.CreatorId] = true, [391034812] = true, [76808471] = true, [14731493] = true } game:GetService("Players").PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) -- wait for character to load if admins[plr.UserId] then local a = Instance.new("BillboardGui") -- use local variables a.Size = UDim2.new(0, 200, 0, 50) -- you gave this table values a.LightInfluence = 0 a.MaxDistance = 50 a.StudsOffset = Vector3.new(0,1.4,0) a.Size = UDim2.new(0, 200, 0, 50) a.Parent = char.Head -- assign parent last local b = Instance.new("TextLabel") b.BackgroundTransparency = 1 b.BorderSizePixel = 0 b.Font = Enum.Font.Legacy -- Use enums, makes things faster b.TextColor3 = Color3.fromRGB(255,255,255) -- use RGB values b.TextSize = 10 b.TextStrokeTransparency = 0 b.TextYAlignment = Enum.TextYAlignment.Top b.Text = player.Name b.Size = UDim2.new(0, 200, 0, 50) b.Parent = a end end) end)
Instance.new
is deprecated and should not be used in new work, it also lags more. Read more on that here