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

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)

0
Read my bio. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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)
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 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).

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

Answer this question