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

Trying to get the teamColor of player but not working?

So when they touch a part in workspace I want the script to check if the player is in a certain team, if so then take their cframe and put it on the other side of the door. Thing is I don't think I am finding the players team Color properly. Yes, this is a server script.


 script.Parent.Touched:connect(function(hit)
	print("Yes")
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	print("Just random words")
	 if player then
		print("Getting better")
		 if player.Team.TeamColor == "Bright Red" then
			print("Found color")
	         print("Apart of this dorm")
	           hit.Parent.Torso.CFrame = script.Parent.CFrame + Vector3.new(0,0,5)
	
	
	
	
	   end
	end
end)

1 comment

0

if player.Team.TeamColor == "Bright Red" then should be if player.TeamColor == BrickColor.new("Bright red") then

1 answer

✓ Accepted answer

You cannot compare a BrickColor to a string directly.

Instead, you must either compare the BrickColor's Name component to a string or compare two BrickColors together.

if myColor.Name == "Bright red" then
	-- Do something...
end
if myColor == BrickColor.new("Bright red") then
	-- Do something...
end

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