So I have a cannonball, and I want to see if it touched a MODEL not a part. But I didn't know where to start, so I thought I would come here. I want it to see if the ball touches the model, and if it touched a model, then you get a point, with a debounce, of course. But I think I can take care of that. For now, can you please help me find witch model, not part, my ball touched?
You have a few options here...
1 is an ugly method called magnitude, works best on circles:
if (part.Position-part2.Position).Magnitude < (whatever the size of part2 is, any axis) then print('in range') end
You can loop it or whatever.
You can use region3, raycasting, .Touched, GetTouchingParts()
local part = workspace.Part for _, v in pairs(part:GetTouchingParts()) do print(v.Name) end
You can loop it again for the next time its touched
then theres the good old .Touched
part.Touched:Connect(function(obj) if obj:IsDescendantOf(workspace.Model) then print('model touched') end end)
You can also do it the other way
for _, v in pairs(model:GetDescendants()) do v.Touched:Connect(function(obj) if obj == part then print('touched part') end end) end
So uh, see which one helps you, gl bye
It is currently not possible to detect if it is touching an entire model but instead you can insert a part into the model and resize it until it is even with the model. Then you can set CanCollide
to false and set Transparency
to 1.
Just detect hits between parts, and detect if its in your desired model. Very simple solution:
if hit.Parent:IsA("Model") and hit.Parent.Name == "YourModel" then