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

How do I fix this dent and transparency script problem?

Asked by 7 years ago

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.

01local DentSpeed = 90
02 
03script.Parent.Touched:Connect(function(part)
04local Speed = script.Parent.Velocity.Magnitude
05    if Speed >= DentSpeed then
06            script.BD2.Transparency = 1
07 
08if script.BD2.Transparency == 1
09    then script.Parent:Destroy()
10end
11        else
12            wait()
13        end
14end)
0
Read my bio. hiimgoodpack 2009 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

Sorry for the Destroy thing! Here is the updated answer!

1local DentSpeed = 90
2local id = --Put the ID here
3 
4script.Parent.Touched:Connect(function(part)
5local Speed = script.Parent.Velocity.Magnitude
6    if Speed >= DentSpeed then
7            script.BD2.Transparency = 1
8       script.BD2.MeshId = "http://www.roblox.com/asset/?id="..id
9end)
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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).

01local DentSpeed = 90
02 
03script.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.BD2.Transparency = 1
08        script.Parent:Destroy()
09    end
10    -->> wait() doesn't do anything
11end)

You'd need to provide more details if this doesn't fix your problem.


Hope I helped!

~TDP

Answer this question