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

Why is it not detecting the color in the If statement?

The second if statement works, if the color is "(255, 148, 148)" it runs and prints, But when the part is Mauve it does nothing, The print before the if statement even prints "mauve" but then doesn't print "WOOOORK".

This must be a studio bug as i have no other explanation...

if Direction.Value == 1 then -- UP
		local NewPosition1 = Assets:FindFirstChild(PixelHeight.Value + 1)
		local NewPosition2 = NewPosition1:FindFirstChild(PixelPlace.Value)
		print(NewPosition2.BrickColor)
		if NewPosition2.BrickColor == "Mauve" then
			print("WOOOORK")
		elseif NewPosition2.Color == Color3.fromRGB(255, 148, 148) then
			print("FOOOD")
			Size.Value = Size.Value + 1
			Food.Value = 0
		end

1 comment

0

I would start debugging it. For example try changing the brick color

1 answer

✓ Accepted answer

You need to use BrickColor.new(), "Mauve" alone is a string and the BrickColor property takes a BrickColor object as its parameter.

if Direction.Value == 1 then -- UP
        local NewPosition1 = Assets:FindFirstChild(PixelHeight.Value + 1)
        local NewPosition2 = NewPosition1:FindFirstChild(PixelPlace.Value)
        print(NewPosition2.BrickColor)
        if NewPosition2.BrickColor == BrickColor.new("Mauve") then -- changed
            print("WOOOORK")
        elseif NewPosition2.Color == Color3.fromRGB(255, 148, 148) then
            print("FOOOD")
            Size.Value = Size.Value + 1
            Food.Value = 0
        end

2 comments

0

Thank you so much!

1

No problem! Glad to help :)

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