I'm working on cars with denting. Basically before all the parts with "script.BD2.Transparency" was replaced with "script.Parent:Destroy()". So, what this means was, sometimes the part would get destroyed before the script finished, so sometimes the next dent mesh wasn't made uninvisible. So I decided to switch them, so the mesh would appear first then the old mesh would get deleted after, but it's not working. Please help.
01 | local DentSpeed = 90 |
02 |
03 | script.Parent.Touched:Connect( function (part) |
04 | local Speed = script.Parent.Velocity.Magnitude |
05 | if Speed > = DentSpeed then |
06 | script.BD 2. Transparency = 1 |
07 |
08 | if script.BD 2. Transparency = = 1 |
09 | then script.Parent:Destroy() |
10 | end |
11 | else |
12 | wait() |
13 | end |
14 | end ) |
Sorry for the Destroy thing! Here is the updated answer!
1 | local DentSpeed = 90 |
2 | local id = --Put the ID here |
3 |
4 | script.Parent.Touched:Connect( function (part) |
5 | local Speed = script.Parent.Velocity.Magnitude |
6 | if Speed > = DentSpeed then |
7 | script.BD 2. Transparency = 1 |
8 | script.BD 2. MeshId = "http://www.roblox.com/asset/?id=" ..id |
9 | end ) |
The wait()
you added is pointless - and so is the if statement that checks if the part is invisible (because that statement only runs if it the code that makes it invisible runs).
01 | local DentSpeed = 90 |
02 |
03 | script.Parent.Touched:Connect( function () |
04 | local Speed = script.Parent.Velocity.Magnitude |
05 | if Speed > = DentSpeed then |
06 | -->> Your if statement was located in here, so it was pointless to have it |
07 | script.BD 2. Transparency = 1 |
08 | script.Parent:Destroy() |
09 | end |
10 | -->> wait() doesn't do anything |
11 | end ) |
You'd need to provide more details if this doesn't fix your problem.
Hope I helped!
~TDP