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

Not changing the color when team is changed?

--// variables //--
local gui = game:GetService("ServerStorage"):WaitForChild("Name")

--// script //--
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if not char.Head:FindFirstChild("Name") then
			local clone = gui:Clone()
			clone.Thing.plr.Text = plr.Name
			local color = plr.TeamColor.Color
			clone.Thing.plr.TextColor3 = color
			clone.Thing.rank.Text = plr:GetRoleInGroup(3135949)
			clone.Parent = game.Workspace:WaitForChild(plr.Name).Head
		end
		--// second part //--
		plr.Team.Changed:Connect(function()
			local color = plr.TeamColor.Color
			char:WaitForChild("Head").Name.Thing.plr.TextColor3 = color
		end)
	end)
end)

The second part isn't working, I don't know why.

1 comment

0

Here's some other information: When I respawn, it will definitely change the color. However, I need it so that when the player changes the team, it IMMEDIATELY changes it's color.

1 answer

✓ Accepted answer
local Group = game:GetService("GroupService"):GetGroupInfoAsync(GROUPID) --this is just if you want the group name
local GUI = game.ReplicatedStorage.Group
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
			local clone = GUI:Clone()
			local color = player.Team.TeamColor.Color
			print(color)
			print(player.Team.Name)
			clone.TextLabel.TextColor3 = color
			clone.Parent = char:WaitForChild("Head")
			clone.TextLabel.Text = Group.Name.." Role:"..player:GetRoleInGroup(GROUPID)
	end)
	player:GetPropertyChangedSignal("Team"):Connect(function()
		local color = player.Team.TeamColor.Color
		print(player.Team.Name)
		print(color)
		game.Workspace[player.Name].Head.Group.TextLabel.TextColor3 = color
	end)
end)


Here is a video of it in action!

2 comments

0

I'll try it out, thanks!

0

So it turns out, "Name" was the BillboardGui, but "Name" was also a property in the head. But this helped anyway, thanks a lot!

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