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

How can I get my Open/Close Owner Only Door to work?

Asked by 9 years ago

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!

2 answers

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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."

0
This is not working... TixyScripter 115 — 9y
Ad
Log in to vote
1
Answered by
Hero_ic 502 Moderation Voter
9 years ago

function onClicked() script.Parent.Parent.OwnerOnlyDoor, OwnerOnlyDoor2, OwnerOnlyDoor3, OwnerOnlyDoor4.BrickColor= 'Really red' end

You forgot the ''

Answer this question