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

How to make a frame fade in smoothly?

Asked by
Dwayder 29
6 years ago
local dialog = script.Parent
local frame = game.LocalPlayer.PlayerGui.ScreenGui.Frame
local sound = game.Workspace.Sound
local Dialog = script.Parent.Parent 

-----------------------------------------------------------------

    local function sassy()
    for i = 1, 10 do

        sound:Play()

        frame.BackgroundTransparency = i/10
        wait(.1)

       end
    end





    Dialog.DialogChoiceSelected:Connect(function(sassy)
     print("working")
    end)

So I'm trying to make a frame fade in smoothly but I don't know why this isn't working. Am I accessing the PlayerGui and DialogChoiceSelected correctly?

1
if transparency, tweenservice or lerping (or looping), if position/size same options + ui:TweenPosition()/ui:TweenSize()/ui:TweenSizeAndPosition() User#20388 0 — 6y

3 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

i dont know about that but i always do like this

local dialog = script.Parent
local frame = game.LocalPlayer.PlayerGui.ScreenGui.Frame
local sound = game.Workspace.Sound
local Dialog = script.Parent.Parent 

-----------------------------------------------------------------

    local function sassy()
    for i = 1,0,-0.1 do

        sound:Play()

        frame.BackgroundTransparency = i
        wait(.1)
       end
    end





    Dialog.DialogChoiceSelected:Connect(function()
     sassy()
    end)
Ad
Log in to vote
1
Answered by 6 years ago

Like that

To make transparency use + and to make visible use -

sound:Play()
for i = 1, 100 do
    frame.BackgroundTransparency = frame.BackgroundTransparency + 0.01
    wait()
end
Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Use TweenService. Tweens are used to interpolate the properties of instances. These can be used to create animations for various Roblox objects. Almost any numeric property can be tweened using TweenService. Note that only specific types of properties can be used with TweenService. The types of properties that can be tweened are:

  • number
  • bool
  • CFrame
  • Rect
  • Color3
  • UDim
  • UDim2
  • Vector2
  • Vector2int16
  • Vector3

TweenService has just one function, TweenService:Create, which takes information about the animation and generates the Tween object which can be used to play the animation. Note that Tweens can animate multiple properties at the same time.

Details on how the interpolation of the tween is to be carried out are given in the tweenInfoparameter of TweenService:Create. The TweenInfo data type includes a range of properties that can be used to achieve various styles of animation, including reversing and looping Tweens.

Multiple tweens can be played on the same object at the same time, but they must not be animating the same property. If two tweens attempt to modify the same property, the initial tween will be cancelled and overwritten by the most recent tween

Although other methods exist for tweening objects, such as GuiObject:TweenSizeAndPosition, TweenService allows multiple properties to be modified and for the animation to be paused and cancelled at any point.

TweenService:Create() takes three parameters. First one is the instance to be tweened. GUI objects, Parts and other kinds of stuff can be placed in the instance parameter. Second one is a TweenInfo used to tween the instance. (see API Reference: TweenInfo for information on that) Last parameter is a table containing all properties that you want to change.

If this helped, please accept the answer. I'm glad to help.

Answer this question