So im creating a game and im trying to think of a way to get a block to detect what block is touching it:
So for example:
Block 1 detects that block 2 is touching it so it spawns a car.
Another example: Block1 detects that block 3 is touching it so it spawns a monkey.
They are just examples, I don't want a full code I just want advice on what I would use, Would i use .Touched or something similar.
Thanks for help.
Well I would advise that you use the Touched Event
of the block in order to detect what it is using and also you can use its perimeters to identify the Part
that it touches something like this..
function detect(hit) -- Beginning a function if hit and hit.Name == "Block1" then -- If statement to check for the name and if the object exists. -- stuff end -- end for if statement end -- end for function. script.Parent.Touched:connect(detect) -- Connects function to event.
I hope I helped and thank you for reading this answer.
~~ KingLoneCat
If you just want to know when an object touches a part, just once (Could stop touching the part at any time), then Touched is good for you. If you want to see if a part is currently touching a part, you'd need to toggle a variable, as well as using tthe 2 events Touched and TouchEnded.