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

How do I make a tween for properties?

Asked by 4 years ago

If I were to make a part to slowly fade away on event, how would it work?

1 answer

Log in to vote
0
Answered by
Lazarix9 245 Moderation Voter
4 years ago

First, you'll have to make all the variables:

local TweenService = game:GetService("TweenService") --To get tweenservice
local part = script.Parent --Assuming that the script's parent is the pat that you'd like to tween.

Now you will need to tell the tween what would you like to do:

local tweeninginfo = TweenInfo.new(

    3, --This is how long the tween would last.
    Enum.EasingStyle.Linear, --Easing style.
    Enum.EasingDirection.Out, --Easing direction
    0, --How many times will it loop? If set to number less then 0, the tween will loop endlessly.
    false, --Will the tween reverse?
    0 --Delay. Notice that you don't have to add a comma after this.
)

local PartProperties = { --Properties of the part that you'd like to change. You don't have to make it a table but I like to do it that way.

    Transparency = 1 --You can add more properties if you want.
}

local tween = TweenService:Create(part, tweeninginfo, PartProperties) --first argument is the part you'd like to tween, second argument is the tweeninfo and third is part properties that you'd like to change.

Now to make it execute when an event is fired, In this example, I'll use the Touched event.

part.Touched:Connect(function(h)

    tween:Play()

end)

And that should work.

1
thxthxthx so much shanelaw12 64 — 4y
Ad

Answer this question