Alright so I'm a horrible horrible scripter, and I'm just starting out really. Here is the script I put together.
T = game.Teams.Parent.Name function Teamon() script.Parent.Text = UDim2.new("Your Team: ")..T() end
This script is suppose to show the player what team they're on. Could someone give me pointers to fix my mistakes?
You define T
as a name, but you use it as a function (line 4).
Properly, it's probably either the team object itself (without the name) or just the name. It might be better to use the Team object itself in case later you wanted to get more information (like the color).
I'm assuming this is in a TextLabel in the StarterGui (PlayerGui).
In that case, the Parent of the TextLabel is probably a ScreenGui, and its parent is probably the PlayerGui; its parent is the Player.
Players are not children of their respective teams - they are children of the Players
service.
You figure out which team they are on by matching their TeamColor
to a Team object's team color:
player = script.Parent.Parent.Parent.Parent teamColor = player.TeamColor allTeams = game:GetService("Teams"):GetChildren() -- all the children of the Teams service for _, team in pairs( allTeams) do -- For each team, if team.TeamColor = teamColor then -- if its TeamColor matches mine, myTeam = team -- then it (team) is my team. end end
myTeam
now refers to the player's team.
When we set Text, we remember that Text is a string. "Your Team: "
is a string. It is not a UDim2.
script.Parent.Text = "Your Team: " .. myTeam.Name