Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't the ImageLabel not turn invisible with my script?

Hello. This is my first time scripting and asking a question, so I probably did a simple mistake. I am making a prank game where the image flashes to make it look animated, but when I enter my code in a script and play it in roblox studio:

ib = game.StarterGui.ScreenGui.Frame.Black
iw = game.StarterGui.ScreenGui.Frame.White
fr = game.StarterGui.ScreenGui.Frame
fr.Visible = false

while wait() do
	fr.Visible = true
	iw.Visible = true
	ib.Visible = false
	wait(.5)
	iw.Visible = false
	ib.Visible = true
	wait(.5)
print("this looped")
end

and I run the game, the visibility box is checking on and off, but the image doesn't turn invisible and not "flashing". I made this a script not a local script. (I already tried localscript and it was the same problem) Here is my explorer: https://imgur.com/ssDYpky

Here is what the script does: https://imgur.com/INxS7II

and here is what I want it to do: https://imgur.com/5CvpR8I

Please help me find a solution to why it doesn't work and what to do to make it work

2 answers

✓ Accepted answer

OK, so first of all. When you are dealing with the User aka.(The Client). You use Local Scripts. Why? Well, the main reason is for Responsiveness.

--Anyways, from what I can see, from your script and what you want it to do. You're trying to affect to many things at once.

  1. Why, are you making the frame not visible and then visible?

  2. Why, are you trying to affect, the black and white image label(s) at the same time?

This is the code that should work :

local SP = script.Parent
local frame1 = SP.Black -- Frame TO Change Visibility On
while wait(.5) do
	frame1.Visible = true
	wait(.5)
	frame1.Visible = false
end

--Other Knowledge-- ~Coding Is very specific, know what you're doing and why.

Hope This Helped!

~Farsalis

4 comments

0

This isn't an answer to the question, it's a rambling of personal dogma, half of which is based on misunderstandings. Server scripts can change individual players' UI, that's not why this code should be in a LocalScript. Responsiveness is why. Items 3 and 4 are misinformation. Item 6 is wrong; you can't make a variable reference to a UserData property like Visible. Item 5.. ironic.

0

Thank you for your help!

0

I dont know how to personally say this, but yeah she's totally right! Until I saw this comment didnt actually know about any of this. Which is why im kinda glad i got to see it. What she says is way better than what I said..and actually right. Though, I don't get how 3 and 4 are misinformation (If you Could explain a bit more). I'll be taking out the items which are Inaccurate.

0

Also, for the dogma, very sorry if it came out that way. Was really doing my best to explain it correctly (Even Though It Was Not). I'll do better with that, and not go on a ramble like that with incorrect information. Also, please accept her answer instead of mine. Thank You.

ib = game.StarterGui.ScreenGui.Frame.Black

StarterGui is just a replication container, the client clones what's in there and puts the copy in game.Players.<your username>.PlayerGui

You can have a LocalScript in StarterGui that does just what you want, but it has to use a relative path, not an absolute path to the prototype copies in StarterGui. For example, if your ScreenGui and LocalScript are both children of StarterGui, the script can access the ScreenGui with script.Parent:WaitForChild("ScreenGui")

2 comments

0

So putting script.Parent:WaitForChild("ScreenGui") will make the script work? (Assuming ScreenGui and LocalScript are both children of StarterGui), or would I have to still fix my script since it's kind of broken?

0

Changing the references to be relative should make it work, at least enough for you to see what the code you wrote actually does, as a starting point. The key is that at Runtime, script.Parent won't be StarterGui, it will be your PlayerGui, because the copy of the script that actually runs will be a clone of what's in StarterGui.

This discussion is preserved as it was. New answers, comments, and votes are closed.