Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

door transparency on click not working?

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

✓ Accepted answer

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

3 comments

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.

0

Wow

0

Indeed, but he didn't ask for anything else other than making the script work.

This discussion is preserved as it was. New answers, comments, and votes are closed.