local NB = Instance.new("Part", game.Workspace) NB.Size = Vector3.new(1,1,1) NB.Position = Vector3.new(0,0,0) NB.Anchored = false NB.Name = "1" print("Ok_1") game.Workspace.PartFolder.ChildAdded:connect(function(Brick) print("Ok_2") wait(1) print(Brick.Name) Brick.Touched:connect(function(Thing) print("Ok_3") print(Thing) end) end) local NB2 = Instance.new("Part", game.Workspace.PartFolder) NB2.Size = Vector3.new(1,1,1) NB2.Position = Vector3.new(0,2,0) NB2.Anchored = false NB2.Name = "2"
Why does it not print what it is touching? Should it not print "1" which is the name of the first part?
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
local debounce = false local NB = Instance.new("Part", game.Workspace) NB.Size = Vector3.new(1,1,1) NB.Position = Vector3.new(0,0,0) NB.Anchored = false NB.Name = "1" print("Ok_1") game.Workspace.PartFolder.ChildAdded:connect(function(Brick) if Brick then print("Ok_2") wait(1) print(Brick.Name) Brick.Touched:connect(function(Thing) if not debounce then debounce = true print("Ok_3") print(Thing) print("poop") wait(3) --changes this to how long you want the script to wait before it can print something again debounce = false end end) end end) local NB2 = Instance.new("Part", game.Workspace.PartFolder) NB2.Size = Vector3.new(1,1,1) NB2.Position = Vector3.new(0,2,0) NB2.Anchored = false NB2.Name = "2"