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

The force of a hit?

Asked by
lucas4114 607 Moderation Voter
9 years ago

Well, I'm not even sure somthing like this is real... So, like a hit there can be a way to check how hard it hit?... I'm trying to make a car that explodes after HARD hits not simply a player walking into it..... Please help me?

0
You could check the velocity of the part hat hit it, although velocity isn't exactly super reliable. Perci1 4988 — 9y
0
Hmm.. Good idea.. Might not work too well I guess.. lucas4114 607 — 9y
0
If your having a problem where it explode when the player walks into it then why don't you make the script check if the Part is just hit has a Humanoid inside and if it does it won't explode and if it doesn't it would explode? UserOnly20Characters 890 — 9y
0
Well, by player walking into it, I ment little hits like that... So mabye a better example would be, the car exploding whenever it lightly touched a wall or sometimes even simply the road under it... lucas4114 607 — 9y

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

What You Need To Do

With a Touched event, you need to get the force of the part that touched!


Formula For Force

The formula for the force of an object is Velocity * Mass.

To get the Velocity of an object, you need to index the Velocity Property of the object.

To get the Mass of an object, you need to use the GetMass function.


Code

part.Touched:connect(function(hit)
    local Xforce = hit.Velocity.X * hit:GetMass()
    local Yforce = hit.Velocity.Y * hit:GetMass()
    local Zforce = hit.Velocity.Z * hit:GetMass()
end)
0
I guess this is good for now... lucas4114 607 — 9y
Ad

Answer this question