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

Script stops printing the count of for loop, and it also doesn't work anymore?

Asked by 4 years ago
Edited 4 years ago

I have this script to make a loading screen, and it has a for loop wich sets the imagelabel's imagetransparency from 1 to 0 and then from 0 to 1. The problem is, it waits 0.4 seconds before changing, stops on -0.8, waits about 2 seconds and just doesn't work anymore. This is the script:

01local Gui = script:WaitForChild("LoadingGui")
02local player = game.Players.LocalPlayer
03local backG = Gui.Back
04local FranXXicon = backG.Icon
05wait(6)
06for i = -1,0,0.1 do
07    wait(0.4)
08    if i == -1 then
09        FranXXicon.ImageTransparency = 1
10        print(i)
11    elseif i == -0.9 then
12        FranXXicon.ImageTransparency = 0.9
13        print(i)
14    elseif i == -0.8 then
15        FranXXicon.ImageTransparency = 0.8
View all 75 lines...

1 answer

Log in to vote
1
Answered by
Memotag 226 Moderation Voter
4 years ago
Edited 4 years ago

I would highly recommend that you use the TweenService to get a smoother change in transparency.

This can be accomplished by doing something like this:

01local TweenService = game:GetService("TweenService")
02local Gui = script:WaitForChild("LoadingGui")
03local player = game.Players.LocalPlayer
04 
05local backG = Gui.Back
06local FranXXicon = backG.Icon
07 
08local TweenInfo = TweenInfo.new(2) -- Change 2 to how long you want it to take
09local Tween = TweenService:Create(FranXXicon, TweenInfo, {ImageTransparency = 1})
10 
11wait(6)
12 
13Tween:Play()

A list of properties that can be altered via TweenService can be found here

0
Never tought you could use tweening to just change properties that aren't position, but ima try it. User#32819 0 — 4y
0
I edited my post to link to the documentation for TweenService:Create Memotag 226 — 4y
0
Yes, it's working. I made two separate tweens, one to fade in and another to fade out. User#32819 0 — 4y
Ad

Answer this question