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

How do i change the color of a brick depending on the team?

What i mean is if you touch a brick if your team is "Red" it will change to Red or if it was blue it would change to blue.

3 answers

✓ Accepted answer
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then --make sure what has been touched is an actual character by checking if it has a humanoid
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- here we get the player object of the character
		assert(plr ~= nil,"what has been touched is not a player's character") -- this breaks the function and errors ("what has been touched is not a player's character") if the condition is false which means that it errors if the character that has been touched is **not** a player's character

		local teamColor = plr.Team.TeamColor --here we directly get the player's Team and then its BrickColor (which is named TeamColor, just for teams only though)
		script.Parent.BrickColor =  teamColor -- and then change the script's parent BrickColor to it.
	end
end)

2 comments

0

Thanks man works great n

0

So glad I helped :D

99% sure this is a troll dude anyway

if team == "Red" then
script.Parent.Color = "Red"
end

3 comments

0

no its not i already see some error ;/

0

Fister, u suck.

0

lol i bet u forgot to put the script in the brick xDDD

try this, its off the top of my head so if it doesn't work don't witch hunt me lol (this would also be in a normal script btw)

local teams = game:GetService("Teams")

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and teams == "Red" then --insert the name of your team
		script.Parent.Color = "Red" --insert the color of the team
end)

i know this most likely didn't work but that's the gist of what your final product will be. Research it more and try to tweak it. Make sure to mark as answered if I helped :D

2 comments

0

This wouldnt work. You're comparing a service to a string called "Red" Also you can't use a string for Color, it needs a Color3 value or something..

0

again, was at the top of my head XD

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