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.
local DentSpeed = 90 script.Parent.Touched:Connect(function(part) local Speed = script.Parent.Velocity.Magnitude if Speed >= DentSpeed then script.BD2.Transparency = 1 if script.BD2.Transparency == 1 then script.Parent:Destroy() end else wait() end end)
Sorry for the Destroy thing! Here is the updated answer!
local DentSpeed = 90 local id = --Put the ID here script.Parent.Touched:Connect(function(part) local Speed = script.Parent.Velocity.Magnitude if Speed >= DentSpeed then script.BD2.Transparency = 1 script.BD2.MeshId = "http://www.roblox.com/asset/?id="..id 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).
local DentSpeed = 90 script.Parent.Touched:Connect(function() local Speed = script.Parent.Velocity.Magnitude if Speed >= DentSpeed then -->> Your if statement was located in here, so it was pointless to have it script.BD2.Transparency = 1 script.Parent:Destroy() end -->> wait() doesn't do anything end)
You'd need to provide more details if this doesn't fix your problem.
Hope I helped!
~TDP