Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a (almost) duplicate line of code in the same script work?

Asked by 1 year ago

Hello!

I recently added a nametag system into my Roblox game which includes an uppertext (player's name), and a lowertext. Now the script and how it works is fine, but whenever I add another line of the "if player.Name == . . ." code after the first one to create a custom lowertext for another specific player, the name tag doesn't appear in-game at all.

Script:

local rep = game:GetService("ReplicatedStorage") local nametag = rep.NameTag

game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local head = char.Head local newtext = nametag:Clone() local uppertext = newtext.UpperText local lowertext = newtext.LowerText

    newtext.Parent = head
    newtext.Adornee = head
    uppertext.Text = player.Name

    if player.Name == "PlayerName" then
        lowertext.Text = "(ex.) Owner"
        lowertext.TextColor3 = Color3.fromRGB(255, 0, 0)

>>> if player.Name == "PlayerName" then
        lowertext.Text = "(ex.) Admin"
        lowertext.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
end)

end)

0
Use "elseif" Ziffixture 6913 — 1y

Answer this question