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

I've tried to use "if" to detect another image but it doesn't work. How do you do it correctly?

Asked by 3 years ago
if game.StarterGui.LoadingGui.LoadingImage.Visible = false  then <-- this line here
    script.Parent.TextTransparency = 0.1
    wait(0.5)
    script.Parent.TextTransparency = 0.2
    wait(0.5)
    script.Parent.TextTransparency = 0.3
    wait(0.5)
    script.Parent.TextTransparency = 0.4
    wait(0.5)
    script.Parent.TextTransparency = 0.5
    wait(0.5)
    script.Parent.TextTransparency = 0.6
    wait(0.5)
    script.Parent.TextTransparency = 0.7
    wait(0.5)
    script.Parent.TextTransparency = 0.8
    wait(0.5)
    script.Parent.TextTransparency = 0.9
    wait(0.5)
    script.Parent.TextTransparency = 1
end
0
Use playergui when trying to get a gui as the playergui is a cointainer that holds the gui's. Also use a numerical for loop for efficiency JesseSong 3916 — 3y
0
Check if it was true using a changed event, This only does it for if it was set to false when the game started. kepiblop 124 — 3y

2 answers

Log in to vote
0
Answered by
Vathriel 510 Moderation Voter
3 years ago

A key pointer here would be to remember that when checking for equality you need to use the double equals symbol.

if game.StarterGui.LoadingGui.LoadingImage.Visible == false then

However, as the comments have suggested it'd probably be better to use a changed event so that you can check immediately after something changes and not just once.

0
Why are you not referencing the player's gui? [Therefore your answer is incorrect] JesseSong 3916 — 3y
Ad
Log in to vote
0
Answered by
2Loos 168
3 years ago

Always remember: A double equal sign (==) is for equality. A single equal (=) sign is for changing some property, like the parent of a part.

Your edit script accounting for these changes:

if game.StarterGui.LoadingGui.LoadingImage.Visible == false  then --Changed this from "=" to "==" to check for equality, not to change something.
    script.Parent.TextTransparency = 0.1
    wait(0.5)
    script.Parent.TextTransparency = 0.2
    wait(0.5)
    script.Parent.TextTransparency = 0.3
    wait(0.5)
    script.Parent.TextTransparency = 0.4
    wait(0.5)
    script.Parent.TextTransparency = 0.5
    wait(0.5)
    script.Parent.TextTransparency = 0.6
    wait(0.5)
    script.Parent.TextTransparency = 0.7
    wait(0.5)
    script.Parent.TextTransparency = 0.8
    wait(0.5)
    script.Parent.TextTransparency = 0.9
    wait(0.5)
    script.Parent.TextTransparency = 1
end
0
Why are you not referencing the player's gui? [Therefore your answer is incorrect] JesseSong 3916 — 3y

Answer this question