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

How do I make this script about impact speed work?

Asked by 7 years ago

How do I make this script about impact speed work? Basically I want a MeshPart to go transparent after it is hit at 90 speed and above. But, this is not working. Can anyone tell me what to do? I'm a rookie scripter and get most of my stuff off the internet.

1script.parent.Touched:Connect(function(hit)
2speed = math.sqrt(hit.Velocity.X^2 + hit.Velocity.Y^2 + hit.Velocity.Z^2)
3print(speed)
4end)
5 
6if speed >= 90 then
7 
8end
9script.parent.Transparency = 1

Script is in a MeshPart on a car. Should the car be anchored?

0
Check your output please. It's .Parent. Lua is Case Sensitive. RubenKan 3615 — 7y
0
I made a solution! TinyScripter 70 — 7y
0
@RubenKan Thank you so much. TheBeaver101 28 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Here you go!

01--Variables
02local DentSpeed = 90 --Set the number to the speed you want
03--Code
04script.parent.Touched:Connect(function(part) --Run this when hit, part is what this hit
05local Speed = script.Parent.Velocity.Magnitude
06    if Speed >= DentSpeed then --If the part is going faster than the speed set, then destroy this script's parent
07            script.Parent:Destroy()
08        else --If not, do nothing
09            wait()
10        end
11end)

Yes, I tested this and it works.

0
It didn't work for me :C Can you invite me to a team create? TheBeaver101 28 — 7y
0
NVM IT WORKS TheBeaver101 28 — 7y
Ad

Answer this question