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:

local Gui = script:WaitForChild("LoadingGui")
local player = game.Players.LocalPlayer
local backG = Gui.Back
local FranXXicon = backG.Icon
wait(6)
for i = -1,0,0.1 do
    wait(0.4)
    if i == -1 then
        FranXXicon.ImageTransparency = 1
        print(i)
    elseif i == -0.9 then
        FranXXicon.ImageTransparency = 0.9
        print(i)
    elseif i == -0.8 then
        FranXXicon.ImageTransparency = 0.8
        print(i)
    elseif i == -0.7 then
        FranXXicon.ImageTransparency = 0.7
        print(i)
    elseif i == -0.6 then
        print(i)
        FranXXicon.ImageTransparency = 0.6
    elseif i == -0.5 then
        print(i)
        FranXXicon.ImageTransparency = 0.5
    elseif i == -0.4 then
        print(i)
        FranXXicon.ImageTransparency = 0.4
    elseif i == -0.3 then
        print(i)
        FranXXicon.ImageTransparency = 0.3
    elseif i == -0.2 then
        print(i)
        FranXXicon.ImageTransparency = 0.2
    elseif i == -0.1 then
        print(i)
        FranXXicon.ImageTransparency = 0.1
    elseif i == -1.3877787807814e-16 then
        print(i)
        FranXXicon.ImageTransparency = 0
    end
end
for i = 0,1,0.1 do
    if i == 0.1 then
        print(i)
        FranXXicon.ImageTransparency = 0.1
    elseif i == 0.2 then
        print(i)
        FranXXicon.ImageTransparency = 0.2
    elseif i == 0.3 then
        print(i)
        FranXXicon.ImageTransparency = 0.3
    elseif i == 0.4 then
        print(i)
        FranXXicon.ImageTransparency = 0.4
    elseif i == 0.5 then
        print(i)
        FranXXicon.ImageTransparency = 0.5
    elseif i == 0.6 then
        print(i)
        FranXXicon.ImageTransparency = 0.6
    elseif i == 0.7 then
        print(i)
        FranXXicon.ImageTransparency = 0.7
    elseif i == 0.8 then
        print(i)
        FranXXicon.ImageTransparency = 0.8
    elseif i == 0.9 then
        print(i)
        FranXXicon.ImageTransparency = 0.9
    elseif i == 1 then
        print(i)
        FranXXicon.ImageTransparency = 1
    end
end

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:

local TweenService = game:GetService("TweenService")
local Gui = script:WaitForChild("LoadingGui")
local player = game.Players.LocalPlayer

local backG = Gui.Back
local FranXXicon = backG.Icon

local TweenInfo = TweenInfo.new(2) -- Change 2 to how long you want it to take
local Tween = TweenService:Create(FranXXicon, TweenInfo, {ImageTransparency = 1})

wait(6)

Tween: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