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?
How to check if a part touched a model?
3 answers
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.
4 comments
Thats actually a good idea. I didn't know though, that you couldn't find a model. One bad thing though, my model is a boat
with a bow and all
Just weld the part to the boat
alright
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
3 comments
I thought that only worked for parts
it only works for baseparts, or unions, but you could detect parent
mate, your answer didn't work XD
This discussion is preserved as it was. New answers, comments, and votes are closed.

9 comments
bye
bye
bye
magnitude is a good choice for squares hitbox, get touching part is useless tbh, 3rd is just check parent and 4th is the best imo, but if you dont want to index anything then my method i guess
Your method is good on performance, magnitude is terrible for square hitboxes. GetTouchingParts is extremely useful, I don't know why you think it's useless, I'd find other ways, methods and other resources though. You could also apply heavy math but that's absurd
Wait that's not even your method, that's Frindows im talking about. Your method is absolutely useless, sorry
Your 3rd script was exactly what I wanted. thanks
I was looking for a way without a loop, and I found it. Xapelize had a good answer, but like....
you mean frindow? xapelizes answer was bad