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

How do i change the player's torso into its team color?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if char then
			local plr = game.Players:GetPlayerFromCharacter(char)
			local color = char:WaitForChild("Body Colors")
			local torso = char:WaitForChild("Torso")
			color.TorsoColor = BrickColor.new(player.TeamColor)
			torso.BrickColor = BrickColor.new(player.TeamColor)
		end
	end)
end)

I don't get it, i have no error at all and it still does nothing. Please help.

2 comments

0

Doesn't your shirt stop you from seeing the color of the torso?

0

Please be more descriptive you can learn how to post a good question/answer here: https://scriptinghelpers.org/help/how-post-good-questions-answers

1 answer

player.TeamColor is a BrickColor already, so you don't need to construct a new one. I'd also like to point out that if their team changes before they load/respawn again, you don't update their color. Give this a try, and lemme know if you have any questions.

game.Players.PlayerAdded:Connect(function(player)
	local currentCharacter = nil

	-- function for updating the colors of the character
	local function updateColors()
		if currentCharacter then
			-- i don't think it's necessary to update the
			-- Torso color directly, so i excluded that
			local bodyColors = character:WaitForChild('Body Colors', 5)
			if bodyColors then
				bodyColors.TorsoColor = player.TeamColor
			end
		end
	end

	player.CharacterAdded:Connect(function(character)
		-- update 'currentCharacter' and call 'updateColors()'
		currentCharacter = character
		updateColors()
	end)
	
	-- if their team changes, update their colors
	player:GetPropertyChangedSignal('Team'):Connect(updateColors)
end)

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