(Please forgive my horrible avatar, this is only an alt account . I was afraid this site was used for phishing.) Let's say I have a block that starts a function when it's touched. How can I get the block that touched it? I think I know, but I haven't tried this yet. If it works, I will close this question. Do I just add the variable name of the touching part in the () argument of the function?
1 | Part = ???? --this is what part will fire the function when it is touched |
2 | Part.Touched:connect( function (PartHit) -- The "PartHit" is the part that hit the part you put in "Part", it doesnt have to be named "PartHit" it can be anything else |
3 | --and put what ever you want it to do here |
4 | end ) |
Yes! Using the TouchedEvent, you can get the part that touches an object!
1 | script.Parent.Touched:connect( function (hit) |
2 | print (hit.Name.. " touched me!" ) |
3 | end ) |