So, anymore improves on this rather insane mess of a script?

local MedParticless, MedParticless2, MedParticless3 = MedPart.Emit:Clone(), MedPart.Emit:Clone(), MedPart.Emit:Clone()

local MedParticles, MedParticles2, MedParticles3 = MedPart.Gassinup:Clone(), MedPart.Gassinup:Clone(), MedPart.Gassinup:Clone()


local Weld = Instance.new("ManualWeld")
Weld.Part0 = Particle
Weld.Part1 = Humrp

local Part = Instance.new("Part")
Part.Size = Vector3.new(2048, 16, 2048)
Part.Position = Vector3.new(0, 333, 0)
Part.Transparency = 1
Part.Massless = true
Part.Anchored = true
Part.Name = "It's Raining outside..."
-----------------Tweens------------------------
local OGTP = TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 1)
local TP = TweenInfo.new(5, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, -1, true, 1)
local OGGoals = {Density = 0.3, Offset = 0.25, Decay = Color3.fromRGB(106, 112, 125), Glare = 0, Haze = 0,}
local OGGoals2 = {FarIntensity = 0.104,	FocusDistance = 4.16, NearIntensity = 0.75}
local Goals = {Density = 0.613, Offset = 0.081, Decay = Color3.fromRGB(175, 185, 206), Glare = 0.32, Haze = 2.26}
local Goals2 = {FarIntensity = 0.5, FocusDistance = 0, NearIntensity = 0.35}
local TransReversal = {BackgroundTransparency = 0}
local NameReversal = {TextTransparency = 0}
local ImageReversal = {ImageTransparency = 0}
local Transss = {BackgroundTransparency = 1}
local NameTra = {TextTransparency = 1}
local ImageTra = {ImageTransparency = 1}
local TriggerEnterLeave = false
------------------Tweens-----------------------
---------------------------------------------------------------------------
local TWAtmo = TweenService:Create(Lighting.Atmosphere, TP, Goals)
local TWBlur = TweenService:Create(Lighting.DepthOfField, TP, Goals2)
local OGTWAtmo = TweenService:Create(Lighting.Atmosphere, OGTP, OGGoals)
local OGTWBlur = TweenService:Create(Lighting.DepthOfField, OGTP, OGGoals2)
local BLOCK1 = TweenService:Create(GUIS["Block off One"], TP, TransReversal)
local BLOCK2 = TweenService:Create(GUIS["BLock off Two"], TP, TransReversal)
local Food = TweenService:Create(GUIS.Parent.MainGUI.Food, TP, Transss)
local FoodBG  = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBarBG, TP, Transss)
local FoodBar = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBar, TP, Transss)
local Qi = TweenService:Create(GUIS.Parent.MainGUI.Qi, TP, Transss)
local QiBar = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBar, TP, Transss)
local QiBarBG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBarBG, TP, Transss)
local Health = TweenService:Create(GUIS.Parent.MainGUI.HP, TP, Transss)
local HealthBar = TweenService:Create(GUIS.Parent.MainGUI.HP.HPBar, TP, Transss)
local HealthBG = TweenService:Create(GUIS.Parent.MainGUI.HP.BarBackground, TP, Transss)
local Names = TweenService:Create(GUIS.Parent.Names.Names, TP, NameTra)
local TC = TweenService:Create(GUIS.Parent.TrainingCreation.ImageLabel, TP, ImageTra)
local Click = TweenService:Create(GUIS.Parent.Click.YinYang, TP, ImageTra)
local COPPACOIN = TweenService:Create(GUIS.Parent.Coins.CopperCoin, TP, ImageTra)
local SILVACOIN = TweenService:Create(GUIS.Parent.Coins.SilverCoin, TP, ImageTra)
local GOLDCOIN = TweenService:Create(GUIS.Parent.Coins.GoldCoin, TP, ImageTra)
local CopperAmo = TweenService:Create(GUIS.Parent.Coins.CopperCoin.CopperAmount, TP, NameTra)
local SilverAmo = TweenService:Create(GUIS.Parent.Coins.SilverCoin.SilverAmount, TP, NameTra)
local GoldAmo = TweenService:Create(GUIS.Parent.Coins.GoldCoin.GoldAmount, TP, NameTra)

-----------------------------------------------------------------------------

local FoodOG = TweenService:Create(GUIS.Parent.MainGUI.Food, TP, TransReversal)
local FoodBGOG  = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBarBG, TP, TransReversal)
local FoodBarOG = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBar, TP, TransReversal)
local QiOG = TweenService:Create(GUIS.Parent.MainGUI.Qi, TP, TransReversal)
local QiBarOG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBar, TP, TransReversal)
local QiBarBGOG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBarBG, TP, TransReversal)
local HealthOG = TweenService:Create(GUIS.Parent.MainGUI.HP, TP, TransReversal)
local HealthBarOG = TweenService:Create(GUIS.Parent.MainGUI.HP.HPBar, TP, TransReversal)
local HealthBGOG = TweenService:Create(GUIS.Parent.MainGUI.HP.BarBackground, TP, TransReversal)
local NamesOG = TweenService:Create(GUIS.Parent.Names.Names, TP, NameReversal)
local TCOG = TweenService:Create(GUIS.Parent.TrainingCreation.ImageLabel, TP, ImageReversal)
local ClickOG = TweenService:Create(GUIS.Parent.Click.YinYang, TP, ImageReversal)
local COPPACOINOG = TweenService:Create(GUIS.Parent.Coins.CopperCoin, TP, ImageReversal)
local SILVACOINOG = TweenService:Create(GUIS.Parent.Coins.SilverCoin, TP, ImageReversal)
local GOLDCOINOG = TweenService:Create(GUIS.Parent.Coins.GoldCoin, TP, ImageReversal)
local CopperAmoOG = TweenService:Create(GUIS.Parent.Coins.CopperCoin.CopperAmount, TP, NameReversal)
local SilverAmoOG = TweenService:Create(GUIS.Parent.Coins.SilverCoin.SilverAmount, TP, NameReversal)
local GoldAmoOG = TweenService:Create(GUIS.Parent.Coins.GoldCoin.GoldAmount, TP, NameReversal)

----------------------------------------------------------------------------
-- \\ Animation-Related Variables //--

local Anim = script.Meditation



-- \\ Functions // --

GUIS.IgnoreGuiInset = true

UIS.InputBegan:Connect(function(Input, Processed, IsTyping)
	local Player = game.Players.LocalPlayer
	local Character = Player.Character or Player.CharacterAdded:Wait()
	TriggerEnterLeave = true
	
	local MedAnim = Character.Humanoid.Animator:LoadAnimation(Anim)
	
	if Meditation1 == true then return end
	
	if not IsTyping then
		
		if Input.KeyCode == Enum.KeyCode.M then			
			if GUIS.Enabled == false then				
				GUIS.Enabled = true

				Circle.MouseEnter:Connect(function()
					
					if not TriggerEnterLeave then return end
					if Meditation1 == false then
					Meditation1 = true
						
					HUM.WalkSpeed = 0
						
					
					local function TweenDone(state)
						if state == Enum.TweenStatus.Completed and Meditation1 == true then
								RS.Progressing:FireServer("MeditationTraining")
								print("Yeah we good")
							else 
								return
							
						end
					end
				--|| Tweens Being Played ||--
					MedAnim:Play()
					BLOCK1:Play()
					BLOCK2:Play()
					MedAnim.Looped = true
					TWAtmo:Play()
					TWBlur:Play()
					Food:Play()
					FoodBar:Play()	
					FoodBG:Play()
					Qi:Play()
					QiBar:Play()
					QiBarBG:Play()
					Health:Play()
					HealthBar:Play()
					HealthBG:Play()
					Names:Play()	
					TC:Play()
					Click:Play()
					COPPACOIN:Play()
					SILVACOIN:Play()
					GOLDCOIN:Play()
					CopperAmo:Play()
					SilverAmo:Play()
					GoldAmo:Play()
					StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
					Part.Parent = workspace
					MedParticles.Parent = Humrp
					MedParticles2.Parent = Character["Right Arm"]
					MedParticles3.Parent = Character["Left Arm"]
						
					MedParticless.Parent = Humrp
					MedParticles2.Parent = Character["Right Arm"]
					MedParticles3.Parent = Character["Left Arm"]
					
						local Emitter = Instance.new("ParticleEmitter", Part)
						Emitter.Rate = 700
						Emitter.Lifetime = NumberRange.new(2, 5)
						Emitter.Size = NumberSequence.new(0.8,2)
						Emitter.Color = ColorSequence.new{
							ColorSequenceKeypoint.new(0, White),
							
							ColorSequenceKeypoint.new(1, White)
						}
						Emitter.SpreadAngle = Vector2.new(-360, 360)
						Emitter.Acceleration = Vector3.new(0, -60, 0)
						coroutine.wrap(function()
							task.wait(4)
							GUI.MainGUI.Enabled = false
							GUI.Names.Enabled = false
							GUI.Coins.Enabled = false
							GUI.TrainingCreation.Enabled = false
						end)
						
											
					while GUIS.Enabled do
						task.wait(1)
							script.Parent.MovingCircle:TweenPosition(UDim2.new(Randomzier:NextNumber(0, 0.962),46 ,Randomzier:NextNumber(0, 0.285),47), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, math.random(5,8), false, TweenDone)
							task.wait(3)
							Food:Pause()
							FoodBar:Pause()	
							FoodBG:Pause()
							Qi:Pause()
							QiBar:Pause()
							QiBarBG:Pause()
							Health:Pause()
							HealthBar:Pause()
							HealthBG:Pause()
							Names:Pause()	
							TC:Pause()
							Click:Pause()
							COPPACOIN:Pause()
							SILVACOIN:Pause()
							GOLDCOIN:Pause()
							CopperAmo:Pause()
							SilverAmo:Pause()
							GoldAmo:Pause()
							
							Particle.Parent = workspace
							
							TWAtmo:Pause()
							TWBlur:Pause()
							BLOCK1:Pause()
							BLOCK2:Pause()
						end
					end		
				
				end)
				
				Circle.MouseLeave:Connect(function()
				TriggerEnterLeave = false
					MedAnim:Stop()
					TWAtmo:Cancel()
					TWBlur:Cancel()
					Food:Cancel()
					FoodBar:Cancel()	
					FoodBG:Cancel()
					Qi:Cancel()
					QiBar:Cancel()
					QiBarBG:Cancel()
					Health:Cancel()
					HealthBar:Cancel()
					HealthBG:Cancel()
					Names:Cancel()	
					TC:Cancel()
					Click:Cancel()
					COPPACOIN:Cancel()
					SILVACOIN:Cancel()
					GOLDCOIN:Cancel()
					CopperAmo:Cancel()
					SilverAmo:Cancel()
					GoldAmo:Cancel()
					OGTWAtmo:Play()
					OGTWBlur:Play()
					FoodOG:Play()
					FoodBarOG:Play()	
					FoodBGOG:Play()
					QiOG:Play()
					QiBarOG:Play()
					QiBarBGOG:Play()
					HealthOG:Play()
					HealthBarOG:Play()
					HealthBGOG:Play()
					NamesOG:Play()	
					TCOG:Play()
					ClickOG:Play()
					COPPACOINOG:Play()
					SILVACOINOG:Play()
					GOLDCOINOG:Play()
					CopperAmoOG:Play()
					SilverAmoOG:Play()
					GoldAmoOG:Play()
					StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
					GUI.MainGUI.Enabled = true
					GUI.Names.Enabled = true
					GUI.Coins.Enabled = true
					GUI.TrainingCreation.Enabled = true
					MedParticles.Parent, MedParticles2.Parent, MedParticles3.Parent, MedParticless.Parent, MedParticless2.Parent, MedParticless3 = game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded")
					Part.Parent = game.ServerStorage:FindFirstChild("Discarded")
					GUIS.Enabled     = false
					HUM.WalkSpeed = 16
					Meditation1      = false
				
					end)
				end
			end
		end
	end)

This a meditation script, but it’s crazy. It looks rather chaotic imo and I wish I could just simplify it, so I’m just a little curious if there is a way to do so, or if not, if theres a way to stop a reoccuring glitch I’m dealing with

I’m not sure if I got everything right but you can add the tween to a table and go through them and modify their state.

local MedParticless, MedParticless2, MedParticless3 = MedPart.Emit:Clone(), MedPart.Emit:Clone(), MedPart.Emit:Clone()
local MedParticles, MedParticles2, MedParticles3 = MedPart.Gassinup:Clone(), MedPart.Gassinup:Clone(), MedPart.Gassinup:Clone()

local Weld = Instance.new("ManualWeld")
Weld.Part0 = Particle
Weld.Part1 = Humrp

local Part = Instance.new("Part")
Part.Size = Vector3.new(2048, 16, 2048)
Part.Position = Vector3.new(0, 333, 0)
Part.Transparency = 1
Part.Massless = true
Part.Anchored = true
Part.Name = "It's Raining outside..."
-----------------Tweens------------------------
local OGTP = TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 1)
local TP = TweenInfo.new(5, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, -1, true, 1)
local OGGoals = {Density = 0.3, Offset = 0.25, Decay = Color3.fromRGB(106, 112, 125), Glare = 0, Haze = 0,}
local OGGoals2 = {FarIntensity = 0.104,	FocusDistance = 4.16, NearIntensity = 0.75}
local Goals = {Density = 0.613, Offset = 0.081, Decay = Color3.fromRGB(175, 185, 206), Glare = 0.32, Haze = 2.26}
local Goals2 = {FarIntensity = 0.5, FocusDistance = 0, NearIntensity = 0.35}
local TransReversal = {BackgroundTransparency = 0}
local NameReversal = {TextTransparency = 0}
local ImageReversal = {ImageTransparency = 0}
local Transss = {BackgroundTransparency = 1}
local NameTra = {TextTransparency = 1}
local ImageTra = {ImageTransparency = 1}
local TriggerEnterLeave = false
------------------Tweens-----------------------
---------------------------------------------------------------------------
local tweenlist :{Tween}&{} = {}
tweenlist.TWAtmo = TweenService:Create(Lighting.Atmosphere, TP, Goals)
tweenlist.TWBlur = TweenService:Create(Lighting.DepthOfField, TP, Goals2)
tweenlist.OGTWAtmo = TweenService:Create(Lighting.Atmosphere, OGTP, OGGoals)
tweenlist.OGTWBlur = TweenService:Create(Lighting.DepthOfField, OGTP, OGGoals2)
tweenlist.BLOCK1 = TweenService:Create(GUIS["Block off One"], TP, TransReversal)
tweenlist.BLOCK2 = TweenService:Create(GUIS["BLock off Two"], TP, TransReversal)
tweenlist.Food = TweenService:Create(GUIS.Parent.MainGUI.Food, TP, Transss)
tweenlist.FoodBG  = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBarBG, TP, Transss)
tweenlist.FoodBar = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBar, TP, Transss)
tweenlist.Qi = TweenService:Create(GUIS.Parent.MainGUI.Qi, TP, Transss)
tweenlist.QiBar = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBar, TP, Transss)
tweenlist.QiBarBG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBarBG, TP, Transss)
tweenlist.Health = TweenService:Create(GUIS.Parent.MainGUI.HP, TP, Transss)
tweenlist.HealthBar = TweenService:Create(GUIS.Parent.MainGUI.HP.HPBar, TP, Transss)
tweenlist.HealthBG = TweenService:Create(GUIS.Parent.MainGUI.HP.BarBackground, TP, Transss)
tweenlist.Names = TweenService:Create(GUIS.Parent.Names.Names, TP, NameTra)
tweenlist.TC = TweenService:Create(GUIS.Parent.TrainingCreation.ImageLabel, TP, ImageTra)
tweenlist.Click = TweenService:Create(GUIS.Parent.Click.YinYang, TP, ImageTra)
tweenlist.COPPACOIN = TweenService:Create(GUIS.Parent.Coins.CopperCoin, TP, ImageTra)
tweenlist.SILVACOIN = TweenService:Create(GUIS.Parent.Coins.SilverCoin, TP, ImageTra)
tweenlist.GOLDCOIN = TweenService:Create(GUIS.Parent.Coins.GoldCoin, TP, ImageTra)
tweenlist.CopperAmo = TweenService:Create(GUIS.Parent.Coins.CopperCoin.CopperAmount, TP, NameTra)
tweenlist.SilverAmo = TweenService:Create(GUIS.Parent.Coins.SilverCoin.SilverAmount, TP, NameTra)
tweenlist.GoldAmo = TweenService:Create(GUIS.Parent.Coins.GoldCoin.GoldAmount, TP, NameTra)

-----------------------------------------------------------------------------
local tweenlistOG :{Tween}&{} = {}
tweenlistOG.FoodOG = TweenService:Create(GUIS.Parent.MainGUI.Food, TP, TransReversal)
tweenlistOG.FoodBGOG  = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBarBG, TP, TransReversal)
tweenlistOG.FoodBarOG = TweenService:Create(GUIS.Parent.MainGUI.Food.FoodBar, TP, TransReversal)
tweenlistOG.QiOG = TweenService:Create(GUIS.Parent.MainGUI.Qi, TP, TransReversal)
tweenlistOG.QiBarOG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBar, TP, TransReversal)
tweenlistOG.QiBarBGOG = TweenService:Create(GUIS.Parent.MainGUI.Qi.QiBarBG, TP, TransReversal)
tweenlistOG.HealthOG = TweenService:Create(GUIS.Parent.MainGUI.HP, TP, TransReversal)
tweenlistOG.HealthBarOG = TweenService:Create(GUIS.Parent.MainGUI.HP.HPBar, TP, TransReversal)
tweenlistOG.HealthBGOG = TweenService:Create(GUIS.Parent.MainGUI.HP.BarBackground, TP, TransReversal)
tweenlistOG.NamesOG = TweenService:Create(GUIS.Parent.Names.Names, TP, NameReversal)
tweenlistOG.TCOG = TweenService:Create(GUIS.Parent.TrainingCreation.ImageLabel, TP, ImageReversal)
tweenlistOG.ClickOG = TweenService:Create(GUIS.Parent.Click.YinYang, TP, ImageReversal)
tweenlistOG.COPPACOINOG = TweenService:Create(GUIS.Parent.Coins.CopperCoin, TP, ImageReversal)
tweenlistOG.SILVACOINOG = TweenService:Create(GUIS.Parent.Coins.SilverCoin, TP, ImageReversal)
tweenlistOG.GOLDCOINOG = TweenService:Create(GUIS.Parent.Coins.GoldCoin, TP, ImageReversal)
tweenlistOG.CopperAmoOG = TweenService:Create(GUIS.Parent.Coins.CopperCoin.CopperAmount, TP, NameReversal)
tweenlistOG.SilverAmoOG = TweenService:Create(GUIS.Parent.Coins.SilverCoin.SilverAmount, TP, NameReversal)
tweenlistOG.GoldAmoOG = TweenService:Create(GUIS.Parent.Coins.GoldCoin.GoldAmount, TP, NameReversal)


----------------------------------------------------------------------------
-- \\ Animation-Related Variables //--
local Anim = script.Meditation

-- \\ Functions // --
GUIS.IgnoreGuiInset = true

UIS.InputBegan:Connect(function(Input, Processed, IsTyping)
	local Player = game.Players.LocalPlayer
	local Character = Player.Character or Player.CharacterAdded:Wait()
	TriggerEnterLeave = true
	local MedAnim = Character.Humanoid.Animator:LoadAnimation(Anim)

	if Meditation1 == true then return end
	if IsTyping then return end
	if Input.KeyCode ~= Enum.KeyCode.M then return end
	if GUIS.Enabled then return end

	GUIS.Enabled = true

	Circle.MouseEnter:Connect(function()
		if not TriggerEnterLeave then return end
		if Meditation1 then return end

		Meditation1 = true
		HUM.WalkSpeed = 0

		local function TweenDone(state)
			if state == Enum.TweenStatus.Completed and Meditation1 == true then
				RS.Progressing:FireServer("MeditationTraining")
				print("Yeah we good")
			else
				return
			end
		end
		--|| Tweens Being Played ||--
		MedAnim:Play()
		MedAnim.Looped = true
		for _,v in pairs(tweenlist) do v:Play() end
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
		Part.Parent = workspace
		MedParticles.Parent = Humrp
		MedParticles2.Parent = Character["Right Arm"]
		MedParticles3.Parent = Character["Left Arm"]

		MedParticless.Parent = Humrp
		MedParticles2.Parent = Character["Right Arm"]
		MedParticles3.Parent = Character["Left Arm"]

		local Emitter = Instance.new("ParticleEmitter", Part)
		Emitter.Rate = 700
		Emitter.Lifetime = NumberRange.new(2, 5)
		Emitter.Size = NumberSequence.new(0.8,2)
		Emitter.Color = ColorSequence.new{
			ColorSequenceKeypoint.new(0, White),
			ColorSequenceKeypoint.new(1, White)
		}
		Emitter.SpreadAngle = Vector2.new(-360, 360)
		Emitter.Acceleration = Vector3.new(0, -60, 0)
		coroutine.wrap(function()
			task.wait(4)
			GUI.MainGUI.Enabled = false
			GUI.Names.Enabled = false
			GUI.Coins.Enabled = false
			GUI.TrainingCreation.Enabled = false
		end)

		while GUIS.Enabled do
			task.wait(1)
			script.Parent.MovingCircle:TweenPosition(UDim2.new(Randomzier:NextNumber(0, 0.962),46 ,Randomzier:NextNumber(0, 0.285),47), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, math.random(5,8), false, TweenDone)
			task.wait(3)
			for _,v in pairs(tweenlist) do v:Pause() end
			Particle.Parent = workspace
		end
	end)

	Circle.MouseLeave:Connect(function()
		TriggerEnterLeave = false
		MedAnim:Stop()
		for _,v in pairs(tweenlist) do v:Cancel() end
		tweenlist.OGTWAtmo:Play()
		tweenlist.OGTWBlur:Play()
		for _,tween in pairs(tweenlistOG) do tween:Play() end
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
		GUI.MainGUI.Enabled = true
		GUI.Names.Enabled = true
		GUI.Coins.Enabled = true
		GUI.TrainingCreation.Enabled = true
		MedParticles.Parent, MedParticles2.Parent, MedParticles3.Parent, MedParticless.Parent, MedParticless2.Parent, MedParticless3 = game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded"), game.ServerStorage:FindFirstChild("Discarded")
		Part.Parent = game.ServerStorage:FindFirstChild("Discarded")
		GUIS.Enabled = false
		HUM.WalkSpeed = 16
		Meditation1 = false
	end)
end)
1 Like