How to exit if statement

Hello,

[color=“fbff00”]TO THOSE OF YOU READING THIS, PLEASE SCROLL DOWN AND READ EVERY MESSAGE i HAVE SENT TO GET MY FULL CONTEXT…I DON’T WANT RESPONSES FROM THOSE WHO JUST READ MY ORIGINAL POST OR TITLE[/color]

-Br, iSyriux

1 Like

You can use break, but you could just leave it as blank and it not do any thing, and still skip down. For break, just literally write the word break without anything else.

4 Likes

Hello,
image

It’s a matter of structuring.
Just negate that condition.

if ajang==5 then
	print('as')
	if game.Players.LocalPlayer...
		repeat wait()...
		if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
			if ar:FindFirstChild("Folder2") then
				print('asr')
				ajang = 6
			end
		end
	end
end

Hello,
Here is my whole script it is a tutorial script

local ajang = 1
game:GetService("RunService").RenderStepped:Connect(function()
	if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
		local ar = game.Players.LocalPlayer.PlayerGui.FlatGui
		if ajang==1 then
			local kr = "Used"
			script.Parent.ImageLabel.Position = UDim2.new(ar[kr].Position.X.Scale+ar[kr].Size.X.Scale/2,0,ar[kr].Position.Y.Scale+ar[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "Access skip menu"
		end
		if ajang==2 then
			local kr = "Other"
			script.Parent.ImageLabel.Position = UDim2.new(ar[kr].Position.X.Scale+ar[kr].Size.X.Scale/2,0,ar[kr].Position.Y.Scale+ar[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "TP to previous level"
		end
		if ajang==3 then
			local kr = "Next"
			script.Parent.ImageLabel.Position = UDim2.new(ar[kr].Position.X.Scale+ar[kr].Size.X.Scale/2,0,ar[kr].Position.Y.Scale+ar[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "TP to next level"
		end
		if ajang==4 then
			local kr = "Spawn"
			script.Parent.ImageLabel.Position = UDim2.new(ar[kr].Position.X.Scale+ar[kr].Size.X.Scale/2,0,ar[kr].Position.Y.Scale+ar[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "TP to spawn"
		end
		if ajang==5 then
			local kr = "Shop"
			script.Parent.ImageLabel.Position = UDim2.new(ar[kr].Position.X.Scale+ar[kr].Size.X.Scale/2,0,ar[kr].Position.Y.Scale+ar[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "Menu screen"
			game:GetService("TweenService"):Create(script.Parent.ImageLabel.TextButton,TweenInfo.new(.7,Enum.EasingStyle.Quint,Enum.EasingDirection.InOut),{Position=UDim2.new(0,0,.5,0)}):Play()
			wait(.3)
			game:GetService("TweenService"):Create(script.Parent.ImageLabel.TextButton,TweenInfo.new(.7,Enum.EasingStyle.Quint),{TextTransparency=1,BackgroundTransparency=1}):Play()
		end
		if ajang==6 then
			local kr = "Change"
			script.Parent.ImageLabel.Position = UDim2.new(ar.Folder2[kr].Position.X.Scale+ar.Folder2[kr].Size.X.Scale/2,0,ar.Folder2[kr].Position.Y.Scale+ar.Folder2[kr].Size.Y.Scale/2,0)
			script.Parent.ImageLabel.TextLabel.Text = "Change UI Theme"
			game:GetService("TweenService"):Create(script.Parent.ImageLabel.TextButton,TweenInfo.new(.7,Enum.EasingStyle.Quint),{TextTransparency=0,BackgroundTransparency=0}):Play()
			wait(.3)
			game:GetService("TweenService"):Create(script.Parent.ImageLabel.TextButton,TweenInfo.new(.7,Enum.EasingStyle.Quint,Enum.EasingDirection.InOut),{Position=UDim2.new(0,0,-0.2,0)}):Play()
		end
		if ajang==7 then
			script.Parent:Destroy()
		end
	end
end)
script.Parent.ImageLabel.TextButton.MouseButton1Click:Connect(function()
	print(ajang)
	if ajang~=5 then
		ajang = ajang+1
	end
	if ajang==5 then
		print('as')
		if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
			local ar = game.Players.LocalPlayer.PlayerGui.FlatGui
			repeat wait() until ar:FindFirstChild("Folder2") or not game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui")
			if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
				-- I WANT TO EXIT OUT of IF STATEMENT!!
			end
			if ar:FindFirstChild("Folder2") then
				print('asr')
				ajang = 6
			end
		end
	end
end)

Hello,
Basically for the fifth step it only activates when you click the menu button, when it activates it moves on to the sixth step. There are two GUI themes however and they are seperate GUIs so if the player switches themes midway it will break the tutorial

Like in the other example, I negated your exit condition and put the statement after it inside.

script.Parent.ImageLabel.TextButton.MouseButton1Click:Connect(function()
	print(ajang)
	if ajang~=5 then
		ajang = ajang+1
	end
	if ajang==5 then
		print('as')
		if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
			local ar = game.Players.LocalPlayer.PlayerGui.FlatGui
			repeat wait() until ar:FindFirstChild("Folder2") or not game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui")
			if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
				if ar:FindFirstChild("Folder2") then
					print('asr')
					ajang = 6
				end
			end
		end
	end
end)

As @MRKYLO20 said, an else statement would also work:

script.Parent.ImageLabel.TextButton.MouseButton1Click:Connect(function()
	print(ajang)
	if ajang~=5 then
		ajang = ajang+1
	end
	if ajang==5 then
		print('as')
		if game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
			local ar = game.Players.LocalPlayer.PlayerGui.FlatGui
			repeat wait() until ar:FindFirstChild("Folder2") or not game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui")
			if not game.Players.LocalPlayer.PlayerGui:FindFirstChild("FlatGui") then
				-- Do nothing
			else
				if ar:FindFirstChild("Folder2") then
					print('asr')
					ajang = 6
				end
			end
		end
	end
end)

These two samples are equivalent.

Ah I see I think you need to you if else statements

Hello,
The other gui theme is called ScreenGui2

Hello,
Also apparently it pauses the tween in sequence 6

Hello,
Basically I want the continue button to move up in sequence 6 and it only stops pausing the tween when i change the gui themes it’s so weird idk why but if you click continue in sequence 6 it moves onto sequence 7 where it basically just deletes the gui and completes the tutorial

Hello,
I also want it to work if the player changes the GUI theme midway, so it will sync up with the other theme

So let me get this straight, you are saying that the whole thing is breaking when you change the theme, while in the middle of the tweens?

Hello,
To activate sequence 5 to move onto sequence 6 you must press the menu button on either gui themes, it doesn’t matter if you already clicked the menu button or not before sequence 5

Hello,
Watch the video I sent,

Hello,
Say the player toggles the menu before sequence 5. If the menu is still on, sequence 5 will immediately go to sequence 6.
Or, say the player switches UI theme in any of the steps, the circly thingy will automatically sync to the middle of whatever button’s in focus. The UI themes have different UI posiitions for each button, and different logic for handling menu toggling.
FlatGui has it so that it moves Folder2 (Which is the folder containing the UI elements for the menu thing I know it’s weird and convoluted but I didn’t make the GUI) And ScreenGui2 has it so that it toggles the visibility in everything in Folder2, thus it stays in the same place. When ScreenGui2 is on, sequence 5 should check for the visibility of one of the GUI instances in Folder2, whereas if FlatGui is on sequence 5 should check for if there is a Folder2 in the GUI, because when it is off Folder2 is parented to the “Main” script and not the GUI itself

1 Like

Hello,
Also, the script I sent isn’t complete yet. It doesn’t include the logic for detecting if I have ScreenGui2 or FlatGui yet, I’m doing the steps first just for FlatGui and then adding the logic for detecting the themes and go from there. Any reply would be appreciated :stuck_out_tongue:

Hello,
Then I thought it was the RunService kept interfering with the tweens by keep changing the position to it so I did a once/gonce boolean where it only does it once and it turns true for each sequence so that way it gives time to do the tween, but yet again, the tween for sequence 5 completely doesn’t work, and the tween for sequence 6 stop a quarter of the way and only resumes when I change the GUI theme.
image
I’m completely stumped. It seems that only the UI position tweens don’t work for Seq5 and 6 and not the other tweens, like text transparency and such.

Hello,
Nevermind. My tweening problem was meticulously solved by Mirza Ghalib’s poetry.