Hello, please may I have some help with this script please? I have no idea why it isn't working...
Please help me correct this please! Thanks.
BuzzerOne=game.Workspace.Buzzers.BuzzerOne BuzzerTwo=game.Workspace.Buzzers.BuzzerTwo BuzzerThree=game.Workspace.Buzzers.BuzzerThree Intro=game.Workspace.Intro function onClick() if BuzzerOne.BrickColor.Red() and BuzzerTwo.BrickColor.Red() and BuzzerThree.BrickColor.Red() then Intro:Play() end end script.Parent.ClickDetector.MouseClick:connect(onClick)
16:53:37.142 - BrickColor is not a valid member of Model 16:53:37.143 - Script 'Workspace.Part.Script', Line 7
BuzzerOne=game.Workspace.Buzzers.BuzzerOne BuzzerTwo=game.Workspace.Buzzers.BuzzerTwo BuzzerThree=game.Workspace.Buzzers.BuzzerThree Buzzers = {BuzzerOne,BuzzerTwo,BuzzerThree} Intro=game.Workspace.Intro function onClick() local isvalid = true for _,v in pairs(Buzzers) do for _,w in pairs(v:GetChildren()) do if w.BrickColor ~= BrickColor.Red() then isvalid = false end end end if isvalid then Intro:Play() end end script.Parent.ClickDetector.MouseClick:connect(onClick)
There were parts inside the models. Those are what you have to test the BrickColor
on, not the model itself as it has no BrickColor
on it.
As the error says,
BuzzerOne
(or ..Two
or ..Three
, I don't know which; but probably all of them) is a Model. Models don't have BrickColor
properties, which is your error. Make BuzzerOne
refer to a part rather than a model.
If it were a part, your code still wouldn't work. You have to compare the values, not just call .Red()
on them. Comparison for equality is done with the ==
operator (read "is equal to"). It is unrelated to the assignment construct =
.
if BuzzerOne.BrickColor == BrickColor.Red() and BuzzerTwo.BrickColor == BrickColor.Red() and BuzzerThree.BrickColor == BrickColor.Red() then
This is just to test with to show that it works this script works with a normal brick, I used name but you could use other. hope this helps
while true do if script.Parent.BrickColor.Name == "Bright red" then print("ok") end wait(5) end