So I am trying to make a Open/Close Owner Only Door for my Robloxian Rebearth Tycoon and for others. I have got this close button so far but there is an error.
function onClicked() script.Parent.Parent.OwnerOnlyDoor, OwnerOnlyDoor2, OwnerOnlyDoor3, OwnerOnlyDoor4.BrickColor= Really red end script.Parent.ClickDetector.MouseClick:connect(onClicked)
There is a red line under end in the script on studio, and when I click the button it doesn't change the color either when I click it. I have multiple Owner Only Doors so its like bars also. Please help!
You have to define each of the BrickColor separately.
function onClicked() local Model = script.Parent.Parent Model.OwnerOnlyDoor.BrickColor = BrickColor.new("Really red") Model.OwnerOnlyDoor2.BrickColor = BrickColor.new("Really red") Model.OwnerOnlyDoor3.BrickColor = BrickColor.new("Really red") Model.OwnerOnlyDoor4.BrickColor = BrickColor.new("Really red") end script.Parent.ClickDetector.MouseClick:connect(onClicked)
There's another way you can achieve the same effect.
-- By using a "for" loop function onClicked() local Model = script.Parent.Parent for i, v in pairs (Model:GetChildren()) do v.BrickColor = BrickColor.new("Really red") end end script.Parent.ClickDetector.MouseClick:connect(onClicked) --[[ THIS WILL ONLY WORK IF EVERYTHING IN script.Parent.Parent IS NOTHING BUT: OwnerOnlyDoor OwnerOnlyDoor2 OwnerOnlyDoor3 OwnerOnlyDoor4]]
EDIT
Sorry, disregard the "3."
function onClicked() script.Parent.Parent.OwnerOnlyDoor, OwnerOnlyDoor2, OwnerOnlyDoor3, OwnerOnlyDoor4.BrickColor= 'Really red' end
You forgot the ''