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

I can't get Brick .Touched to work when i put a Part into a folder, can someone tell me what is up?

Asked by 7 years ago
01local NB = Instance.new("Part", game.Workspace)
02NB.Size = Vector3.new(1,1,1)
03NB.Position = Vector3.new(0,0,0)
04NB.Anchored = false
05NB.Name = "1"
06 
07print("Ok_1")
08 
09game.Workspace.PartFolder.ChildAdded:connect(function(Brick)
10 
11    print("Ok_2")
12 
13    wait(1)
14 
15    print(Brick.Name)
View all 30 lines...

Why does it not print what it is touching? Should it not print "1" which is the name of the first part?

1 answer

Log in to vote
0
Answered by
iddash 45
7 years ago
Edited 7 years ago

Here. I changed the event to only work if the part isn't equal to nil. I also added Debounce so that it dosen't just print loads of stuff at once. If you want to learn about Debounce go here: http://wiki.roblox.com/index.php?title=Debounce

01local debounce = false
02local NB = Instance.new("Part", game.Workspace)
03NB.Size = Vector3.new(1,1,1)
04NB.Position = Vector3.new(0,0,0)
05NB.Anchored = false
06NB.Name = "1"
07 
08print("Ok_1")
09 
10game.Workspace.PartFolder.ChildAdded:connect(function(Brick)
11    if Brick then
12        print("Ok_2")
13 
14        wait(1)
15 
View all 38 lines...
Ad

Answer this question