I'm pretty new to scripting and I'm sure pretty much all of this is wrong but I don't know where. :<
Anyone have any general tips or new things I could learn to make this code work?
The code seems to see my if statements as false/nil since it doesn't print how its changing color but I don't know how to make it see it correctly
local BPlate = game.Workspace.BasePlate if BPlate.BrickColor ==("Dark stone grey") then --If the color is Dark stone grey wait(1) print('Changing color to Cyan!') BPlate.BrickColor = BrickColor.new('Cyan') --change it to Cyan end if BPlate.BrickColor ==("Dark Stone grey") then --Also this doesn't work either print('Color change failed!') end if BPlate.BrickColor ==("Cyan") then wait(1) print('Changing color to Dark Stone Grey!') BPlate.BrickColor = BrickColor.new('Dark stone grey') end
You must include the datatype
, even if it's in an if
statement.
--In this example, BrickColor is the datatype. Always include BrickColor.new() when referring to BrickColors (also to CFrames, Vector3s, Color3s, etc) if BPlate.BrickColor = BrickColor.new("Dark stone grey") then wait(1) BPlate.BrickColor = BrickColor.new("Cyan") end
Mostly everything is right but when you want to check if a brickcolor you would need to create a brickcolor. Example if basplate.BrickColor = BrickColor("Cyan")
local BPlate = game.Workspace.BasePlate if BPlate.BrickColor ==BrickColor.new("Dark stone grey") then --If the color is Dark stone grey wait(1) print('Changing color to Cyan!') BPlate.BrickColor = BrickColor.new('Cyan') --change it to Cyan end if BPlate.BrickColor ==BrickColor.new("Dark Stone grey") then --Also this doesn't work either print('Color change failed!') end if BPlate.BrickColor ==BrickColor.new("Cyan") then wait(1) print('Changing color to Dark Stone Grey!') BPlate.BrickColor = BrickColor.new('Dark stone grey') end
All I did was add BrickColor.new infront of your conditions :)