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

What value type is brick color?

So I have this script that gets the color of a brick then compares it to a string value in the player. If it's the same then it should print the color of the block. But it never runs even though ColorValue and BloxColor are the same. I think brick colors are a different value type than string, but I can't figure out which.

local PlayerPlayer = game.Players:FindFirstChild(Torso.Parent.Name)
local ColorValue = PlayerPlayer:FindFirstChild("Value").Value
local BloxColor = Blox.BrickColor
if ColorValue == BloxColor then
	print("BloxColor")
end

3 comments

1

im think you mean a vector or a color3

1

its saying Value.Value does not equal to Blox.BrickColor

1

Is Torso at the 1st line referenced by a variable?

2 answers

✓ Accepted answer

You can get the type of each value using the type() function:

print(type(BloxColor))
print(type(ColorValue))

Also, the reason why it isn't working is because BloxColor is a BrickColor but ColorValue is a Color3. BrickColortakes a BrickColor, which is interpreted by a string containing the BrickColor, not a matrix like Color3. If you want to compare the two values, replace Blox.BrickColor with Blox.Color:

local PlayerPlayer = game.Players:FindFirstChild(Torso.Parent) -- Here's the other problem: You were trying to use a method on the Name property
local ColorValue = PlayerPlayer:FindFirstChild("Value").Value
local BloxColor = Blox.Color -- This is a Color3, not a BrickColor
if ColorValue == BloxColor then
	print(BloxColor) -- Prints the Color3, which gives you a matrix
end

2 comments

0

Ok, thank you everyone for the help. I realize I should have put more context in my question, but I think all your advice had the same idea. MCAndRobloxUnited's answer really made it click for me when I realized that BrickColor isn’t a string value. So another easy fix I found was changing BrickColoro to BrickColor.Name if anyone else has this issue. Thank you for the help everybody!

0

Also, thanks for the tip with print(type(xxxx)). I haven't used that before so I learned something new.

	local PlayerPlayer = game.Players.LocalPlayer.Character:FindFirstChild(Torso.Parent.Name) -- the torso is in the character not the player
	local ColorValue = PlayerPlayer:FindFirstChild("Value") -- u cant do values in in a variable pretty sure
	local BloxColor = Blox.BrickColor
	if ColorValue.Value == BloxColor then
	    print("BloxColor")	
end

its kinda hard to understand what u wanted but i hope this works

1 comment

0

Presumably they're using a ServerScript, meaning that LocalPlayer won't exist.

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