So I have this button script:
01 | local owner = script.Parent.Parent.Parent.Parent:WaitForChild( "Owner" ) |
02 |
03 | function onClicked(playerthatclicked) |
04 | if playerthatclicked = = owner.Value then |
05 | local Model = script.Parent.Parent |
06 | Model.OwnerOnlyDoor.BrickColor = BrickColor.new( "Really red" ) |
07 | Model.OwnerOnlyDoor 2. BrickColor = BrickColor.new( "Really red" ) |
08 | Model.OwnerOnlyDoor 3. BrickColor = BrickColor.new( "Really red" ) |
09 | Model.OwnerOnlyDoor 4. BrickColor = BrickColor.new( "Really red" ) |
10 | end |
11 | end |
12 |
13 | script.Parent.closeclick.MouseClick:connect(onClicked) |
The almighty Goulstem helped me edit this script to get it to this. There is still the same problem though. Since I want the owner to be the only one able to open/close the OwnerOnlyDoor for the tycoon I added a playerthatclicked script to it. This changed nothing all it did was cause absolutely nothing to happen in the output in-game and in studio even when the owner is the one clicking it. Please help!
01 | local owner = script.Parent.Parent.Parent.Parent:WaitForChild( "Owner" ) |
02 |
03 | function onClicked(playerthatclicked) |
04 | if playerthatclicked = = owner.Value then |
05 | local Model = script.Parent.Parent |
06 | Model.OwnerOnlyDoor.BrickColor = BrickColor.new( "Really red" ) |
07 | Model.OwnerOnlyDoor 2. BrickColor = BrickColor.new( "Really red" ) |
08 | Model.OwnerOnlyDoor 3. BrickColor = BrickColor.new( "Really red" ) |
09 | Model.OwnerOnlyDoor 4. BrickColor = BrickColor.new( "Really red" ) |
10 | end |
11 | end |
12 |
13 | script.Parent.ClickDetector.MouseClick:connect(onClicked) -- I changed this lined. |
On line 4
, you're comparing playerthatclicked
with owner.Value. But you never set a parameter for your function named playerthatclicked - it's a nil value. So you'd end up with an error like Attempt to compare with a nil value
or something like that.
Also, you neglected to add an 'end' for your if statement on line 4
Just add a parameter to your onClicked
function on line 3
and name it playerthatclicked.
Add an extra end
01 | local owner = script.Parent.Parent.Parent.Parent:WaitForChild( "Owner" ) |
02 |
03 | function onClicked(playerthatclicked) |
04 | if playerthatclicked = = owner.Value then |
05 | local Model = script.Parent.Parent |
06 | Model.OwnerOnlyDoor.BrickColor = BrickColor.new( "Really red" ) |
07 | Model.OwnerOnlyDoor 2. BrickColor = BrickColor.new( "Really red" ) |
08 | Model.OwnerOnlyDoor 3. BrickColor = BrickColor.new( "Really red" ) |
09 | Model.OwnerOnlyDoor 4. BrickColor = BrickColor.new( "Really red" ) |
10 | end |
11 | end |
12 |
13 | script.Parent.closeclick.MouseClick:connect(onClicked) |