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

How to detect if a part is a certain color?

I have a brick, and I want to make an "if then" function..

For example, if the color is Really Blue, then make the part's transparency .5. I'm not sure how to make a script detect the color... any help?

EDIT: Why doesn't this work?

Brick = script.Parent AnotherBrick = game.Workspace.TP

if game.Workspace.Screen.brickcolor.Name == "Bright green" then Brick.Touched:connect(function(part) if part.Parent.Humanoid then -- * if part.Parent.Humanoid.Health > 0 then part.Parent:MoveTo(AnotherBrick.Position) end end end)

2 answers

if game.Workspace.Part.brickColor.Name == "Really blue"
	then
	game.Workspace.Part.Transparency = 0.5
end

This line of code will take the children of a certain location and apply the transformation if the colour of the child is Really blue:

local children = game.Workspace.Model:GetChildren() -- the game.Workspace.Model should be changed to the place you want to search for the part at.

for i = 1, #children do
	if children[i]:IsA("BasePart") == true and children[i].BrickColor == "Really Blue" then
		children[i].Transparency = 0.5
	end
end

2 comments

0

Thank you, but read my edited description.. I need help with the second part now

0

It's hard to read the way you laid it out, but I spotted a couple errors. Send me a Roblox message with the script and I'll try to help you further!

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