Bear with me here, please. I have this script in a brick:
1 | local Library 3 = require(Workspace.Start) |
2 | script.Parent.Touched:connect( function (hit) |
3 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
4 | Library 3. start(script.Parent.Parent.Parent) |
5 | end |
6 | end ) |
I have this in a ModuleScript:
01 | local Library 3 = { } |
02 | function Library 3. start(item) |
03 | function scan(item) |
04 | if item:FindFirstChild( "Rotor" ) then |
05 | item.Rotor.BrickColor = BrickColor.new( 1020 ) |
06 | elseif item:FindFirstChild( "Alert" ) then |
07 | item.Alert.BrickColor = BrickColor.new( 1020 ) |
08 | item.Alert.Transparency = 0 |
09 | end |
10 | if #item:GetChildren() > 0 then |
11 | for _,v in pairs (item:GetChildren()) do |
12 | scan(v) |
13 | end |
14 | end |
15 | end |
16 | end |
17 | return Library 3 |
When a player touches the brick, it's supposed to call the module script, which is then supposed to scan all the bricks in the model to find "Alert" and "Rotor" and make the necessary changes to their properties. Touching the brick produces no effect however. Anything I'm doing wrong here?
You have a misplaced end
.
01 | local Library 3 = { } |
02 |
03 | Library 3 [ "start" ] = function (item) |
04 | function scan(item) |
05 | if item:FindFirstChild( "Rotor" ) then |
06 | item.Rotor.BrickColor = BrickColor.new( 1020 ) |
07 | elseif item:FindFirstChild( "Alert" ) then |
08 | item.Alert.BrickColor = BrickColor.new( 1020 ) |
09 | item.Alert.Transparency = 0 |
10 | end |
11 | end |
12 | if #item:GetChildren() > 0 then |
13 | for _,v in pairs (item:GetChildren()) do |
14 | scan(v) |
15 | end |
16 | end |
17 | end |
18 |
19 | return Library 3 |
REMEMBER
Formating is IMPORTANT. Readability
is arguably more important than Functionality
.