hello im a newbie in scripting and i'm making a game and it has 3 teams i created a gui with textlabel and the text change in base of the team name , colors too but it dosent work, how can i fix it?
local player = game:GetService("Players") if player.Team == ("clandestin") then script.Parent.TextLabel.Text = player.Team.Name script.Parent.TextLabel.BackgroundColor3 = Color3.fromRGB(190, 71, 11) end if player.Team == ("cittadino") then script.Parent.TextLabel.Text = player.Team.Name script.Parent.TextLabel.BackgroundColor3 = Color3.fromRGB(0, 255, 0) end if player.Team == ("controllore") then script.Parent.TextLabel.Text = player.Team.Name script.Parent.TextLabel.BackgroundColor3 = Color3.fromRGB(22, 67, 190) end
Btw please use Lua Code Block for future questions.
local plr = game.Players.LocalPlayer local chr = plr.Character or plr.CharacterAdded:Wait() -- makes sure player loaded in before script ran if plr.TeamColor == "" then script.Parent.TextLabel.Text = "" script.Parent.TextLabel.TextColor = "" elseif plr.TeamColor == "" then script.Parent.TextLabel.Text = "" script.Parent.TextLabel.TextColor = "" elseif plr.TeamColor == "" then script.Parent.TextLabel.Text = "" script.Parent.TextLabel.TextColor = "" end
Change TeamColor to the color of the team.
so i changed the script and now is
local plr = game.Players.LocalPlayer if plr.TeamColor == "CGA Brown" then script.Parent.Text = "clandestin" script.Parent.TextColor = "CGA Brown" elseif plr.TeamColor == "Lapis" then script.Parent.Text = "controllore" script.Parent.TextColor = "Lapis" elseif plr.TeamColor == "Lime green" then script.Parent.Text = "cittadino" script.Parent.TextColor = "Lime green" end -- this script is from SitaruDaniel, credit added by 322ita--
but there is an error saying Players.322ita.PlayerGui.ScreenGui.TextLabel.Script:3: attempt to index nil with 'TeamColor'
what should i do?