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

how do i make it so the part is fading?

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)

1 comment

0

I'd recommend you use TweenService for this

2 answers

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.

1 comment

0

^ Additionally, I recommend adding a debounce so the fade doesn't repeat while it's already in progress.

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.

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