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

Why doesn't this work?

Asked by
DVDKO 20
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
logo = game.StarterGui.ScreenGui.JoinGui.Enter.Logo.ImageTransparency
logo = 1

for i = 1, 0, -0.1 do
    wait()
    logo = i
end

I'm trying to make the ImageLabel fade in, but this doesn't work ;-;

1 answer

Log in to vote
3
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

The First Problem

This is actually a very common mistake I see people make. The variable logo is set to the value of game.StarterGui.ScreenGui.JoinGui.Enter.Logo.ImageTransparency which is a number (Try printing logo to see what I mean).

Then because of this, on line 6 you are trying to equate logo with i but logo is a number. It makes no sense to say something like 0.5 = 0.1.

What you want to do is get the location of the ImageLabel Logo and then set it's ImageTransparency to i.

local logo = game.StarterGui.ScreenGui.JoinGui.Enter.Logo
logo.ImageTransparency = 1

for i = 1, 0, -0.1 do
    wait()
    logo.ImageTransparency = i
end

The Second Problem

However this script still won't work how you're expecting it to. The problem now is that you are setting the ImageTransparency of the ImageLabel Logo that is in the StarterGui instead of the ImageTransparency of the ImageLabel Logo of the current player.

The best way to do this is to use a the property of Players LocalPlayer. This holds the value of the current player on that particular client, and thus must be used in a LocalScript to work.

LocalScript:

local player = game.Players.LocalPlayer
local logo = player.PlayerGUI.ScreenGui.JoinGui.Enter.Logo
logo.ImageTransparency = 1

for i = 1, 0, -0.1 do
    wait()
    logo.ImageTransparency = i
end

I think that you'll find that you'll almost always want to use a LocalScript when working with GUIs, as it runs local to that player's computer, and each player's GUIs are local to that player as well.

Ad

Answer this question