How can I make this Transparency transition smoother?

I want to make it smooth, how do I do?
Here’s the code:

local part = script.Parent
local folderbib = game.Workspace.Biblio
local folderhall = game.Workspace.SpawnHallway

part.Touched:Connect(function()
	for i,v in pairs(folderbib:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.Transparency = 0.8
		end
	end
	
	for i,v in pairs(folderhall:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.Transparency = 0
		end
	end
end)

And here’s an example:
https://gyazo.com/4ed9724927d6e3b0da688bb5d1f7566a

Use TweenService to change the transparency or add a wait() for each time it loops

local TweenService = game:GetService("TweenService")
local part = script.Parent
local folderbib = game.Workspace.Biblio
local folderhall = game.Workspace.SpawnHallway
local TI = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

part.Touched:Connect(function()
	for i,v in pairs(folderbib:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			local A = TweenService:Create(v, TI, {Transparency = 0.8})
			A:Play()
			A.Completed:Wait()
		end
	end

	for i,v in pairs(folderhall:GetDescendants()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			local A = TweenService:Create(v, TI, {Transparency = 0})
			A:Play()
			A.Completed:Wait()
		end
	end
end)

like the person above mentioned, using tweenservice could help

1 Like

That’s what I was trying to do, I used your code and it’s half working.
i don’t know you but everything turns transparent really slowly
https://gyazo.com/dd46922f8bb626a7b21f771510c11cad

(I’ve changed the time too)

local TI = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
The first number controls the time, you can change it to like 0.05, etc

Oh yeah I guess, I was lowering it to .1 max

or you could try removing the A.Completed:Wait()

Yeah, now it’s really faster, but the game freezes so i’ll just stick with lowering the tween.info time, thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.