How should I detect if something is colliding in an if statement?

  1. What do you want to achieve?
    I’m trying to make a placing system in a tool, but I need the script to detect if the object is colliding with any other object (Roblox terrain doesn’t matter)

  2. What is the issue?
    I have zero ideas on how to detect if something is colliding in an if statement.

  3. What solutions have you tried so far?
    I have tried using Touched but it isn’t working.

Please could you help?

1 Like

Use spatial queries and check for any object in it’s table

2 Likes

spatial queries are a good idea, but uh… i cant find any good help guides on the topic

1 Like

The api references are
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartBoundsInBox
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartBoundsInRadius
https://developer.roblox.com/en-us/api-reference/function/WorldRoot/GetPartsInPart
and i might as well just give a quick summary of all of them
workspace:GetPartBoundsInBox will return an array of all parts whose bounding boxes are within the given vector3 box space

workspace:GetPartBoundsInRadius will return an array of all parts whose bounding boxes overlap the given radius in your position, mostly used with sphere’s/cylinders/ round meshes

workspace:GetPartsInPart will return an array whose geometry overlaps the specified part’s geometry, this is the most accurate of the three but uses more resources

also there are overlapparams which are basically raycastparams but for collision stuff

3 Likes