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

how do i make it so the part is fading?

Asked by
Cikeruw 14
2 years ago

this is what i got

function onTouched() wait(.1) for i = 0,1,0.1 do script.Parent.Transparency = (i)

script.Parent.CanCollide = false
wait(3)
script.Parent.Transparency = 0
script.Parent.CanCollide = true

end end script.Parent.Touched:Connect(onTouched)

0
I'd recommend you use TweenService for this echobloxia 21 — 2y

2 answers

Log in to vote
0
Answered by
Hypoxla 125
2 years ago

It seems you are trying to use a for loop, but you used it incorrectly. in order to slowly fade the transparency of your part.

function onTouched() 
    script.Parent.CanCollide = false
    for i = 0, 1 ,0.1 do 
        script.Parent.Transparency = i
        wait(0.1)
    end
    wait(3)
    script.Parent.Transparency = 0
    script.Parent.CanCollide = true
        end

script.Parent.Touched:Connect(onTouched)

What this should do is turn off the part's collision after you touch it, and then it will slowly become transparent, increasing transparency by 0.1 every 0.1 seconds. After it becomes fully transparent, it will wait 3 seconds, and then set the part's transparency back to 0 and enables collision.

Let me know if you encounter any problems or if you need any additional help.

0
^ Additionally, I recommend adding a debounce so the fade doesn't repeat while it's already in progress. Hypoxla 125 — 2y
Ad
Log in to vote
0
Answered by 1 year ago

It's pretty easy:

function onTouched()
    script.Parent.CanCollide = false
    for i = 0, 1, 0.03 do
        script.Parent.Transparency = i
        wait(0.03)
    end
    wait(3)
    script.Parent.Transparency = 0
    script.Parent.CanCollide = true
end


script.Parent.Touched:Connect(onTouched)

Like @Hypoxla, it will make it not collide-able, then fade it, wait 3 seconds, make it collide-able, then set transparency to 0.

Answer this question