Strange behaviour

Simply, when I use a local script to edit guis it doesn’t work.

The local script it located inside StarterGui(Previously located in the button itself it still didn’t work then.

Script:

script.Parent.ScreenGui.Frame.Help.MouseButton1Up:Connect(function()
	local black = script.Parent.Black.Blackout
	local Main = script.Parent.Main.Main
	local ScreenGui = script.Parent.ScreenGui
	repeat task.wait(0.001)
		black.Transparency -= 0.1
		print(black.Transparency)
		if black.Transparency == 0 then
			Main.Visible = true -- This part failed
			ScreenGui.Enabled = false -- This part failed as well
		end
		print(black.Transparency)
		if Main.Visible == true then
			print("Visible")
		else
			warn("Failed")
		end
	until black.Transparency <0
	repeat task.wait(0.1)
		black.Transparency += 0.1 
	until black.Transparency == 1
end)

Output:

image

My goal is to make a blackout frame that goes from transparent to not transparent and when its at 0 transparency(when it first appears) I want it to Disable a Gui and make a frame Visible, that’s what went wrong.

(Sorry if my grammar is bad, not sure what’s on today with my grammar.

If you’re waiting for black.Transparency to reach 0, why check it in the loop? If it finishes anyway you make it visible outside of the loop

repeat task.wait(0.001)
	black.Transparency -= 0.1
	print(black.Transparency)
until black.Transparency < 0

--> black.Transparency would already be 0 after the loop

Main.Visible = true
ScreenGui.Enabled = false

I would also recommend using TweenService for your animations. Although, this is nothing to worry about (I believe you’re still learning). You can learn this service once you have time.