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

How can you script BackgroundTransparency Cleanly?

I've been a bit stuck on how to cleanly script BackgroundTransparency without doing this.

script.Parent.Frame.BackgroundTransparency = 0.1
wait(0.05)
script.Parent.Frame.BackgroundTransparency = 0.2
 -- And on and on, its stressful and unclean.

How can you script it to where it makes it cleanly play through the Transparency Frames?

Thank you for you're time.

2 answers

✓ Accepted answer

You can use tweens to smoothly animate properties and get the result you want.

local TweenService = game:GetService("TweenService")
local object = script.Parent.Frame

local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

local goals = {
	BackgroundTransparency = 1
}

local tween = TweenService:Create(object, TweenInfo, goals)

tween:Play()

2 comments

0

I'll try it

0

ye, that's a good one, but long

You can just use for loop, which will repeat script needed amount of time

Here's the code:

for i = 1,9 do
	wait(0.05)
	script.Parent.Frame.BackgroundTransparency = tonumber("0."..i) -- convert 9 to 0.9
end

And that's just it!

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