You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make the script work?
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried rearranging the script around a bit, but nothing has worked yet soo…
Script:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:connect(function(char)
local Nametag = script.NameTag:Clone()
Nametag.Parent = plr.Character.Head
plr.Character.Humanoid.NameDisplayDistance = 0 -- line 5
Nametag.name.Text = plr.Name
Nametag.name.TextColor3 = plr.Team.TeamColor.Color
Nametag.Rank.TextColor3 = plr.Team.TeamColor.Color
if plr:IsInGroup(5925127) and plr.Team ~= game.Teams.Patient then
Nametag.Rank.Text = plr:GetRoleInGroup(5925127)
else
Nametag.Rank.Text = plr.Team.Name
end
if plr:IsInGroup(000) then
Nametag.Dev.Visible = true
Nametag.Dev.Text = plr:GetRoleInGroup(000)
if plr.Name == "49dec" then
Nametag.Dev.Text = "Development Director"
end
else
Nametag.Dev.Visible = false
end
if plr.Team == game.Teams["Death Unit"] then
print(1)
Nametag.name.Text = ""
Nametag.Rank.Text = "Death Unit"
Nametag.name.TextColor3 = BrickColor.Black()
end
if plr:IsInGroup(5927318) and plr.Team == game.Teams["Emergency Response Team"] then
Nametag.Rank.Text = "[SOU] ".. plr:GetRoleInGroup(5927318)
end
if plr.Team == game.Teams["Site Security"] then
if plr:IsInGroup(000) then
Nametag.Rank.Text = plr:GetRoleInGroup(000)
else
Nametag.Rank.Text = "Cadet"
end
end
if plr.Team == game.Teams["Foxtrot Moderation Team"] then
Nametag.Rank.TextColor3 = Color3.fromRGB(41, 98, 255)
Nametag.Rank.Text = "Official Foxtrot Moderator"
Nametag.name.TextColor3 = Color3.fromRGB(170, 0, 255)
Nametag.name.Text = plr.Name
end
if plr.Team == game.Teams["Specialized Protection Unit"] then
if plr:IsInGroup(5927358) then
Nametag.Rank.Text = "[REDACTED]"
Nametag.name.Text = ""
end
if plr.Team == game.Teams["Hospital Intelligence"] then
if plr:IsInGroup(5927255) then
Nametag.Rank.Text = "[EXPUNGED]"
Nametag.name.Text = ""
Nametag.name.TextColor3 = BrickColor.Black()
end
if plr.Team == game.Teams["Specialised Operations Unit"] then
if plr:IsInGroup(5927318) then
Nametag.Rank.Text = plr:GetRoleInGroup(5927318)
else
Nametag.Rank.Text = "SOU Cadet"
end
if plr.Team == game.Teams["Patient Leader"] then
Nametag.Rank.Text = "Patient Leader"
Nametag.name.TextColor3 = BrickColor.Gold()
end
end
end
end
end) -- line 69
if plr.Team == game.Teams["Specialized Protection Unit"] then
if plr:IsInGroup(5927358) then
Nametag.Rank.Text = "[REDACTED]"
Nametag.name.Text = ""
end
This line is also not closed properly. You have two ifs but only one end.
if plr:IsInGroup(000) then
Nametag.Dev.Visible = true
Nametag.Dev.Text = plr:GetRoleInGroup(000)
if plr.Name == "49dec" then
Nametag.Dev.Text = "Development Director"
end
else
Nametag.Dev.Visible = false
end
if plr.Team == game.Teams["Death Unit"] then
print(1)
Nametag.name.Text = ""
Nametag.Rank.Text = "Death Unit"
Nametag.name.TextColor3 = BrickColor.Black()
end
if plr:IsInGroup(5927318) and plr.Team == game.Teams["Emergency Response Team"] then
Nametag.Rank.Text = "[SOU] ".. plr:GetRoleInGroup(5927318)
end
if plr.Team == game.Teams["Site Security"] then
if plr:IsInGroup(000) then
Nametag.Rank.Text = plr:GetRoleInGroup(000)
else
Nametag.Rank.Text = "Cadet"
end
end
if plr.Team == game.Teams["Foxtrot Moderation Team"] then
Nametag.Rank.TextColor3 = Color3.fromRGB(41, 98, 255)
Nametag.Rank.Text = "Official Foxtrot Moderator"
Nametag.name.TextColor3 = Color3.fromRGB(170, 0, 255)
Nametag.name.Text = plr.Name
end
if plr.Team == game.Teams["Specialized Protection Unit"] then
if plr:IsInGroup(5927358) then
Nametag.Rank.Text = "[REDACTED]"
Nametag.name.Text = ""
end
if plr.Team == game.Teams["Hospital Intelligence"] then
if plr:IsInGroup(5927255) then
Nametag.Rank.Text = "[EXPUNGED]"
Nametag.name.Text = ""
Nametag.name.TextColor3 = BrickColor.Black()
end
if plr.Team == game.Teams["Specialised Operations Unit"] then
if plr:IsInGroup(5927318) then
Nametag.Rank.Text = plr:GetRoleInGroup(5927318)
else
Nametag.Rank.Text = "SOU Cadet"
end
if plr.Team == game.Teams["Patient Leader"] then
Nametag.Rank.Text = "Patient Leader"
Nametag.name.TextColor3 = BrickColor.Gold()
end
end
end
end)
end)
if plr.Team == game.Teams["Specialised Operations Unit"] then
if plr:IsInGroup(5927318) then
Nametag.Rank.Text = plr:GetRoleInGroup(5927318)
end -- I added an end to here, and it got rid of the error soo..
else
Nametag.Rank.Text = "SOU Cadet"
end
You shouldn’t simply “put an end… oh the errors gone… so why isn’t it working?”
Double check all your ifs statements and where they close.
I fixed your entire code, your whole issue’s just your if statements not closing where they’re supposed to.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:connect(function(char)
local Nametag = script.NameTag:Clone()
Nametag.Parent = plr.Character.Head
plr.Character.Humanoid.NameDisplayDistance = 0 -- line 5
Nametag.name.Text = plr.Name
Nametag.name.TextColor3 = plr.Team.TeamColor.Color
Nametag.Rank.TextColor3 = plr.Team.TeamColor.Color
if plr:IsInGroup(5925127) and plr.Team ~= game.Teams.Patient then
Nametag.Rank.Text = plr:GetRoleInGroup(5925127)
else
Nametag.Rank.Text = plr.Team.Name
end
if plr:IsInGroup(000) then
Nametag.Dev.Visible = true
Nametag.Dev.Text = plr:GetRoleInGroup(000)
if plr.Name == "49dec" then
Nametag.Dev.Text = "Development Director"
end
else
Nametag.Dev.Visible = false
end
if plr.Team == game.Teams["Death Unit"] then
print(1)
Nametag.name.Text = ""
Nametag.Rank.Text = "Death Unit"
Nametag.name.TextColor3 = BrickColor.Black()
end
if plr:IsInGroup(5927318) and plr.Team == game.Teams["Emergency Response Team"] then
Nametag.Rank.Text = "[SOU] " .. plr:GetRoleInGroup(5927318)
end
if plr.Team == game.Teams["Site Security"] then
if plr:IsInGroup(000) then
Nametag.Rank.Text = plr:GetRoleInGroup(000)
else
Nametag.Rank.Text = "Cadet"
end
end
if plr.Team == game.Teams["Foxtrot Moderation Team"] then
Nametag.Rank.TextColor3 = Color3.fromRGB(41, 98, 255)
Nametag.Rank.Text = "Official Foxtrot Moderator"
Nametag.name.TextColor3 = Color3.fromRGB(170, 0, 255)
Nametag.name.Text = plr.Name
end
if plr.Team == game.Teams["Specialized Protection Unit"] then
if plr:IsInGroup(5927358) then
Nametag.Rank.Text = "[REDACTED]"
Nametag.name.Text = ""
end
end
if plr.Team == game.Teams["Hospital Intelligence"] then
if plr:IsInGroup(5927255) then
Nametag.Rank.Text = "[EXPUNGED]"
Nametag.name.Text = ""
Nametag.name.TextColor3 = BrickColor.Black()
end
end
if plr.Team == game.Teams["Specialised Operations Unit"] then
if plr:IsInGroup(5927318) then
Nametag.Rank.Text = plr:GetRoleInGroup(5927318)
else
Nametag.Rank.Text = "SOU Cadet"
end
end
if plr.Team == game.Teams["Patient Leader"] then
Nametag.Rank.Text = "Patient Leader"
Nametag.name.TextColor3 = BrickColor.Gold()
end
end)
end) -- line 69
The script editor also has this useful thing, use it to check.
How do you usually write your code? Does your Script Editor autocomplete scopes when opened? Usually you should be able to catch these issues immediately when you come across a red underline. There’s also an option in the context menu to view the offending line.
You can catch these pretty quickly if you use proper indenting and close your scopes first before writing the body for that scope. For example, if I’m writing out a function, the Script Editor will usually close that scope for me. If it doesn’t, I write out the end and align it first before anything else.