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

My script has no errors, but it doesn't work?

Asked by 9 years ago

Here is my updated script (thanks everyone!):

if game.Workspace.Light1.BrickColor == ("Bright yellow")and
   game.Workspace.Light2.BrickColor == ("Bright yellow")and
   game.Workspace.Light3.BrickColor == ("Bright yellow") then
game.Workspace.Door1.Position = Vector3.new(-49, 6.99, 8.5)
game.Workspace.Door2.Position = Vector3.new(-60, 6.99, 8.5)
end 

The door's position doesn't change when all three bricks are Bright yellow?

Help?

Thank you

1 answer

Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

I use to do the same thing. BrickColors are not string values. They are BrickColor values. Therefore, you need to check like this:

if game.Workspace.Light1.BrickColor == BrickColor.new("Bright yellow") then

Also keep in mind, however, that if statements only run once. Unless you have other code surrounding that, it will only check if all three bricks are bright yellow a single time, and will not care if they are all bright yellow later. If statements only run once.

0
Thank you, but in order to make the doors change positions, will my script work? DrCylonide 158 — 9y
0
They should change positions, if you follow my advice in the answer. Otherwise, they won't. Perci1 4988 — 9y
0
Okay, I changed the BrickColor part, and I only need the script to check once, to open the doors once, but nothing happened? DrCylonide 158 — 9y
0
If you just put an if statement inside a script, it will check as soon as the game starts. The bricks might not even be loaded at that time. Perci1 4988 — 9y
Ad

Answer this question