Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make this script about impact speed work?

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.

script.parent.Touched:Connect(function(hit)
speed = math.sqrt(hit.Velocity.X^2 + hit.Velocity.Y^2 + hit.Velocity.Z^2)
print(speed)
end)

if speed >= 90 then 

end
script.parent.Transparency = 1

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

3 comments

0

Check your output please. It's .Parent. Lua is Case Sensitive.

0

I made a solution!

0

@RubenKan Thank you so much.

1 answer

✓ Accepted answer

Here you go!

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

Yes, I tested this and it works.

2 comments

0

It didn't work for me :C Can you invite me to a team create?

0

NVM IT WORKS

This discussion is preserved as it was. New answers, comments, and votes are closed.