Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How does this work?

Asked by 9 years ago

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

2 answers

Log in to vote
1
Answered by
DevChris 235 Moderation Voter
9 years ago

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
Ad
Log in to vote
0
Answered by 9 years ago

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 :)

0
Since this wasn't explained very clearly, I'll include a better explanation below. DevChris 235 — 9y

Answer this question