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

door transparency on click not working?

Asked by 4 years ago
Edited 4 years ago
local db = false
script.Parent.ClickDetector.MouseClick:Connect(function()

    script.Parent.Transparency = 0.1
    wait(0.1)
    script.Parent.Transparency = 0.2
    wait(0.1)
    script.Parent.Transparency = 0.3
    wait(0.1)
    script.Parent.Transparency = 0.4
    wait(0.1)
    script.Parent.Transparency = 0.5
    wait(0.1)
    script.Parent.Transparency = 0.6
    wait(0.1)
    script.Parent.Transparency = 0.7
    wait(0.1)
    script.Parent.Transparency = 0.8
    wait(0.1)
    script.Parent.Transparency = 0.9
    wait(0.1)
    script.Parent.Transparency = 1
    script.Parent.CanCollide = false
    db = true
    wait(2)

 if script.Parent.Transparency == 1 then

    script.Parent.Transparency = 0.9
    wait(0.1)
    script.Parent.Transparency = 0.8
    wait(0.1)
    script.Parent.Transparency = 0.7
    wait(0.1)
    script.Parent.Transparency = 0.6
    wait(0.1)
    script.Parent.Transparency = 0.5
    wait(0.1)
    script.Parent.Transparency = 0.4
    wait(0.1)
    script.Parent.Transparency = 0.3
    wait(0.1)
    script.Parent.Transparency = 0.2
    wait(0.1)
    script.Parent.Transparency = 0.1
    wait(0.1)
    script.Parent.Transparency = 0
    script.Parent.CanCollide = true
    db = true
    wait(2)
end
end)
db = false

Yes i do have a clickdectector in my union(part). Yes this is in the same script. Could have made a shortcut with local .. = .. but decided to not do that.

This is meant to make it so if the door is clicked alrdy it should be transparency = 1 after 1 second + cancollide = false and if transparency = 1 then when u click it should make the door go from transparency 1 to 0 so its fully visible + making it so u cant go through it, added debounce which doesnt work either, Im really confused.

Pls help.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

this should fix it:

local db = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if transparency == 0 then
    script.Parent.Transparency = 0.1
    wait(0.1)
    script.Parent.Transparency = 0.2
    wait(0.1)
    script.Parent.Transparency = 0.3
    wait(0.1)
    script.Parent.Transparency = 0.4
    wait(0.1)
    script.Parent.Transparency = 0.5
    wait(0.1)
    script.Parent.Transparency = 0.6
    wait(0.1)
    script.Parent.Transparency = 0.7
    wait(0.1)
    script.Parent.Transparency = 0.8
    wait(0.1)
    script.Parent.Transparency = 0.9
    wait(0.1)
    script.Parent.Transparency = 1
    script.Parent.CanCollide = false
    db = true
    wait(2)
end
 if script.Parent.Transparency == 1 then

    script.Parent.Transparency = 0.9
    wait(0.1)
    script.Parent.Transparency = 0.8
    wait(0.1)
    script.Parent.Transparency = 0.7
    wait(0.1)
    script.Parent.Transparency = 0.6
    wait(0.1)
    script.Parent.Transparency = 0.5
    wait(0.1)
    script.Parent.Transparency = 0.4
    wait(0.1)
    script.Parent.Transparency = 0.3
    wait(0.1)
    script.Parent.Transparency = 0.2
    wait(0.1)
    script.Parent.Transparency = 0.1
    wait(0.1)
    script.Parent.Transparency = 0
    script.Parent.CanCollide = true
    db = true
    wait(2)
end
end)
db = false

0
This answer could work, but you are encouraging the fact that he is wasting lines of code. Maybe you should have used a for loop. U_srname 152 — 4y
0
Wow U_srname 152 — 4y
0
Indeed, but he didn't ask for anything else other than making the script work. Vinceberget 1420 — 4y
Ad

Answer this question