Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Answered] Team GUI, help?

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?

2 comments

1

You need to slow down. WHY are you putting each word of this script down? Throwing things down that "look" like Lua is NEVER a way to write a script.

0

Yeah I really need more practice. :l

1 answer

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

2 comments

1

Thanks for your help, I have a clearer sense of scripting now. The wiki really confuses me. :l

1

For future reference - I hope you come back - the most helpful question on a post should be marked as "accepted" by the question asker. It helps mark threads as resolved so that they can be locked and answerers can better focus their energies

This discussion is preserved as it was. New answers, comments, and votes are closed.