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

Touched event get point of contact?

Asked by
asadefa 55
5 years ago

I am trying to make an explosion for my projectile. How can get the point of contact when the touched event is fired? The touched event gives me the the part I hit. How can I get the exact point of contact.

1script.Parent.Touched:Connect(function(hit)
2    --get the point of contact
3end)

2 answers

Log in to vote
1
Answered by
Despayr 505 Moderation Voter
5 years ago

Not sure if it is possible, but there is a way around this. As soon as the part is touched, you could clone the explosion and set it's position to the part with the 'Touched' function connected to it.

01script.Parent.Touched:Connect(function(hit)
02 
03local expl = game.ServerStorage.Explosion:Clone()
04expl.Position = script.Parent.Position
05expl.Parent = workspace
06 
07 
08 
09 
10 
11end)
Ad
Log in to vote
1
Answered by
poke7667 142
5 years ago

If you are doing a projectile, id recommend ray casting over this as I believe it works for a point of contact (it works for me at least). Here are the docs on: Raycasting

Answer this question