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

How To Detect Object Collisions?

Asked by 10 years ago

How would I script a collision check between a object and part? The model being model1 and the object being a declared as theobject.

if model1 (collides with) theobject

I have no idea on what the collides with collision check should be and I can't seem to find it anywhere. Any help much appreciated.

0
As long as the objects aren't being CFramed into eachother (and collide because of roblox physics/body objects) then you could use the Touched event to detect collision. nate890 495 — 10y
0
Like model1.Touched:connect(function(theobject)? skunk940 10 — 10y
0
for _, part in pairs(model1:GetChildren()) do part.Touched:connect(function(hit) print(part.Name.. " collided with ".. hit.Name) end) end nate890 495 — 10y
0
??? skunk940 10 — 10y
View all comments (5 more)
0
Whenever a part that's child of "model1" is touched, "PartName collided with HitName" will be printed. nate890 495 — 10y
0
touched by what? skunk940 10 — 10y
0
By another part. nate890 495 — 10y
0
How can this be changed so it only happens when a select part touches it? skunk940 10 — 10y
0
local object = game.Workspace.Part; for _, part in pairs(model1:GetChildren()) do; part.Touched:connect(function(hit); if hit == object then; print(part.Name.. " collided with ".. hit.Name); end; end); end nate890 495 — 10y

Answer this question