Ad
Still have questions? Join our Discord server and get real time help.
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 2 days 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 3389 — 2d
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 36 — 2d

2 answers

Log in to vote
0
Answered by
Vathriel 477 Moderation Voter
2 days 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 3389 — 2d
Ad
Log in to vote
0
Answered by
2Loos 108
2 days 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 3389 — 2d

Answer this question