Typewrite text effect not working on an if statement

I’m trying to make it so when the background of the GUI is visible the typewriter effect will work
but it’s not working and I get no errors?



local function typewrite(object,text)
	for i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		wait(0.05)
	end
end

 if script.Parent.Backround.Visible == true then
typewrite(textLabel,"Congratulations, you got the code right rookie")
	print("Text ran")
end

In the video, you can see the Gui works but not the text effect.
https://gyazo.com/8d1b47dd60db1321ac2aef1cb057b009

script.Parent.Backround:GetPropertyChangedSignal("Visible"):Connect(function()
	if script.Parent.Backround.Visible then
		typewrite(textLabel,"Congratulations, you got the code right rookie")
		print("Text ran")
	end
end)

Use thsi instead of

 if script.Parent.Backround.Visible == true then
typewrite(textLabel,"Congratulations, you got the code right rookie")
	print("Text ran")
end

The code I sent will run each time the Backround visible property is changed and if it was changed to true

2 Likes

Thanks a lot! this will help me with stuff later on

1 Like

Glad to be of help! If you have anymore issues don’t be afraid to make another post!