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

Why team shown in GUI is not my team?

Hello.

I'm new to Roblox, so excuse me if this question is stupid, but I didn't find anything in wiki.

I've created 2 teams "Mafias" and "Policemen". For now, I assign all players to mafias team. But in-game, every player gets Policemen team, I don't know why.

My code:

local mafiaTeam = nil
local policeTeam = nil

function onPlayerAdded(player)
	player.Neutral = false
	player.TeamColor = mafiaTeam.TeamColor -- set to mafia	
end

function setUp()
	mafiaTeam = Instance.new("Team", Game:GetService("Teams"))
	mafiaTeam.Name = "Mafias"
	mafiaTeam.TeamColor = BrickColor.Red()
	policeTeam = Instance.new("Team", Game:GetService("Teams"))
	policeTeam.Name = "Policemen"
	policeTeam.TeamColor = BrickColor.Blue()
end

setUp()
Game.Players.PlayerAdded:connect(onPlayerAdded)

What's the problem? If you can figure it out, help me please.

Thanks in advance

UPDATE: as it seems to be, the problem is with GUI. Physically, I'm in mafias team (I've checked player's properties with server console + my name color is red, as it should be if I'm in mafias team), but GUI shows that I'm in policemen team. Any suggestions?

3 comments

0

I think this is most likely just a time issue -- I believe your script is working and it's simply acting too soon and the ROBLOX game is overriding your change. Try adding a wait(1) to the beginning of the player event. (I can't run this code to test). Remember that you can use Tools -> Start Server and Tools -> Start Player to test things like this from Studio and get output!

0

Thanks, but that didn't help. However, I've checked the player's TeamColor and it's set to 'Bright red', but in the GUI I see that he's in Policemen team.

0

Here is the screenshot of GUI http://yadi.sk/d/73Pknat1MZwPx

1 answer

Most likely the issue is, that the 'Play solo' mode loads player earlier than script get's to load. That is common and very frustrating problem, so instead do 'Start server' and within server 'Start player'.

4 comments

0

I've read about it in Wiki, so I'm launching the server and client together. I'll try to launch them separately

0

OK, that didn't help either.

0

Updated the question

0

Is there a way to manualy update GUI?

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