function Thumbstick.Enable(B)Enabled=true ThumbstickFrame.Visible=true local a=MasterControl:GetHumanoid()enableAutoJump(a)end function Thumbstick.Disable(B)Enabled=false if RevertAutoJumpEnabledToFalse then local B=MasterControl:GetHumanoid()if B then B.AutoJumpEnabled=false end end ThumbstickFrame.Visible=false OnMoveTouchEnded()end function Thumbstick.Create(a,B)if ThumbstickFrame then ThumbstickFrame:Destroy()ThumbstickFrame=nil if OnTouchMovedCn then OnTouchMovedCn:disconnect()OnTouchMovedCn=nil end if OnTouchEndedCn then OnTouchEndedCn:disconnect()OnTouchEndedCn=nil end if OnRenderSteppedCn then OnRenderSteppedCn:disconnect()OnRenderSteppedCn=nil end if TouchActivateCn then TouchActivateCn:disconnect()TouchActivateCn=nil end end local R=40 local N=58 local o=13 local l=o+5 local L=2 local w=50 local P=B.AbsoluteSize local O=math.min(P.x,P.y)>500 if O then R=R*2 N=N*2 o=o*2 l=l*2 L=L*2 w=w*2 end local D=Color3.fromRGB(255,255,255)local function Y(B)if B then ThumbstickFrame.Size=UDim2.new(1,0,.4,0)ThumbstickFrame.Position=UDim2.new(0,0,.6,0)else ThumbstickFrame.Size=UDim2.new(1,0,.5,18)ThumbstickFrame.Position=UDim2.new(0,0,.5,-18)end end ThumbstickFrame=Instance.new("\070\114\097\109\101")ThumbstickFrame.Name="\068\121\110\097\109\105\099\084\104\117\109\098\115\116\105\099\107\070\114\097\109\101"ThumbstickFrame.Active=false ThumbstickFrame.Visible=false ThumbstickFrame.BackgroundTransparency=1.0 ThumbstickFrame.BackgroundColor3=Color3.fromRGB(0,0,0)Y()StartImage=Instance.new("\073\109\097\103\101\076\097\098\101\108")StartImage.Name="\084\104\117\109\098\115\116\105\099\107\083\116\097\114\116"StartImage.Visible=false StartImage.BackgroundTransparency=1 StartImage.Image=IMAGE_RING StartImage.AnchorPoint=Vector2.new(.5,.5)StartImage.Parent=ThumbstickFrame EndImage=Instance.new("\073\109\097\103\101\076\097\098\101\108")EndImage.Name="\084\104\117\109\098\115\116\105\099\107\069\110\100"EndImage.Visible=false EndImage.BackgroundTransparency=1 EndImage.Image=IMAGE_DISK EndImage.ImageTransparency=.2 EndImage.AnchorPoint=Vector2.new(.5,.5)EndImage.Parent=ThumbstickFrame for B=1,NUM_MIDDLE_IMAGES,1 do MiddleImages[B]=Instance.new("\073\109\097\103\101\076\097\098\101\108")MiddleImages[B].Name="\084\104\117\109\098\115\116\105\099\107\077\105\100\100\108\101"MiddleImages[B].Visible=false MiddleImages[B].BackgroundTransparency=1 MiddleImages[B].Image=IMAGE_DISK MiddleImages[B].ImageTransparency=MIDDLE_TRANSPARENCIES[B]MiddleImages[B].AnchorPoint=Vector2.new(.5,.5)MiddleImages[B].Parent=ThumbstickFrame end local x=nil local function z(B)if B=="\067\117\114\114\101\110\116\067\097\109\101\114\097"then if x then x:Disconnect()x=nil end local B=workspace.CurrentCamera if B then local a=B.ViewportSize local R=a.X<a.Y Y(R)x=(B:GetPropertyChangedSignal("\086\105\101\119\112\111\114\116\083\105\122\101")):Connect(function()a=B.ViewportSize R=a.X<a.Y Y(R)end)end end end workspace.Changed:Connect(z)if workspace.CurrentCamera then z("\067\117\114\114\101\110\116\067\097\109\101\114\097")end local s=nil local G=nil local C=nil local c=nil local J=nil local v=nil local function M(B)MasterControl:AddToPlayerMovement(-currentMoveVector)currentMoveVector=B local a=currentMoveVector.magnitude if a<L then currentMoveVector=Vector3.new()else currentMoveVector=currentMoveVector.unit*(1-math.max(0,(w-currentMoveVector.magnitude)/w))currentMoveVector=Vector3.new(currentMoveVector.x,0,currentMoveVector.y)end MasterControl:AddToPlayerMovement(currentMoveVector)end local W=nil local j=nil OnRenderSteppedCn=RunService.RenderStepped:Connect(function(B)if W~=nil then local B=tick()-W local a=(FadeInAndOutHalfDuration*2)*FadeInAndOutBalance ThumbstickFrame.BackgroundTransparency=1-FadeInAndOutMaxAlpha*math.min(B/a,1)if B>a then j=tick()W=nil end elseif j~=nil then local B=tick()-j local a=FadeInAndOutHalfDuration*2-(FadeInAndOutHalfDuration*2)*FadeInAndOutBalance ThumbstickFrame.BackgroundTransparency=(1-FadeInAndOutMaxAlpha)+FadeInAndOutMaxAlpha*math.min(B/a,1)if B>a then j=nil end end end)local function d(B,a)local L=R/2+o local w=L local P=a-B local O=((P.magnitude-R/2)-N/2)-o/2 local D=P.unit local Y=w+l*NUM_MIDDLE_IMAGES local x=0 if Y>O then x=l else x=O/NUM_MIDDLE_IMAGES end for B=1,NUM_MIDDLE_IMAGES,1 do local R=MiddleImages[B]local N=L+x*(B-1)if N<O then local B=a-D*N R.Visible=true R.Position=UDim2.new(0,B.X,0,B.Y)R.Size=UDim2.new(0,o,0,o)else R.Visible=false end end end local function q(B)local a=Vector2.new(v.X,v.Y)-ThumbstickFrame.AbsolutePosition local N=Vector2.new(B.X,B.Y)-ThumbstickFrame.AbsolutePosition local o=N-a local l=o.magnitude local L=ThumbstickFrame.AbsoluteSize.X l=math.min(l,L)o=o*l EndImage.Position=UDim2.new(0,N.X,0,N.Y)EndImage.Size=UDim2.new(0,R,0,R)d(a,N)end ThumbstickFrame.InputBegan:connect(function(B)if B.UserInputType~=Enum.UserInputType.Touch or B.UserInputState~=Enum.UserInputState.Begin then return end if c then if not s then s=B G=tick()C=B.Position end return end c=B J=tick()v=B.Position local a=Vector2.new(B.Position.X-ThumbstickFrame.AbsolutePosition.X,B.Position.Y-ThumbstickFrame.AbsolutePosition.Y)StartImage.Visible=true StartImage.Position=UDim2.new(0,a.X,0,a.Y)StartImage.Size=UDim2.new(0,N,0,N)EndImage.Visible=true EndImage.Position=StartImage.Position EndImage.Size=UDim2.new(0,R,0,R)if FadeInAndOutBackground then local B=LocalPlayer:FindFirstChildOfClass("\080\108\097\121\101\114\071\117\105")local a=false if B then if B.CurrentScreenOrientation==Enum.ScreenOrientation.LandscapeLeft or B.CurrentScreenOrientation==Enum.ScreenOrientation.LandscapeRight then a=HasFadedBackgroundInLandscape HasFadedBackgroundInLandscape=true elseif B.CurrentScreenOrientation==Enum.ScreenOrientation.Portrait then a=HasFadedBackgroundInPortrait HasFadedBackgroundInPortrait=true end end if not a then FadeInAndOutHalfDuration=FADE_IN_OUT_HALF_DURATION_DEFAULT FadeInAndOutBalance=FADE_IN_OUT_BALANCE_DEFAULT W=tick()end end end)OnTouchMovedCn=UserInputService.TouchMoved:connect(function(B,a)if B==c then local a=Vector2.new(B.Position.x-v.x,B.Position.y-v.y)if math.abs(a.x)>0 or math.abs(a.y)>0 then M(a)q(B.Position)end end end)OnMoveTouchEnded=function()StartImage.Visible=false EndImage.Visible=false for B=1,NUM_MIDDLE_IMAGES,1 do MiddleImages[B].Visible=false end c=nil MasterControl:AddToPlayerMovement(-currentMoveVector)currentMoveVector=Vector3.new(0,0,0)end local T=pcall(function()local function B(B,a)if B.X<a.AbsolutePosition.X+a.AbsoluteSize.X and(B.X>a.AbsolutePosition.X and(B.Y<a.AbsolutePosition.Y+a.AbsoluteSize.Y and B.Y>a.AbsolutePosition.Y))then return true end return false end TouchActivateCn=UserInputService.TouchTapInWorld:connect(function(a,R)if not R and(Enabled and(not IsAToolEquipped and B(a,ThumbstickFrame)))then MasterControl:DoJump()end end)end)if not T then local function B(B,a,R)if not IsAToolEquipped and tick()-B<TOUCH_IS_TAP_TIME_THRESHOLD then if(R-a).magnitude<TOUCH_IS_TAP_DISTANCE_THRESHOLD then MasterControl:DoJump()end end end OnTouchEndedCn=UserInputService.TouchEnded:connect(function(a,R)if a==c then B(J,v,a.Position)OnMoveTouchEnded()elseif a==s then B(G,C,a.Position)s=nil end end)else OnTouchEndedCn=UserInputService.TouchEnded:connect(function(B,a)if B==c then OnMoveTouchEnded()elseif B==s then s=nil end end)end GuiService.MenuOpened:connect(function()if c then OnMoveTouchEnded()end if s then s=nil end end)local Z=LocalPlayer:FindFirstChildOfClass("\080\108\097\121\101\114\071\117\105")while not Z do LocalPlayer.ChildAdded:wait()Z=LocalPlayer:FindFirstChildOfClass("\080\108\097\121\101\114\071\117\105")end local I=nil local y=Z.CurrentScreenOrientation==Enum.ScreenOrientation.LandscapeLeft or Z.CurrentScreenOrientation==Enum.ScreenOrientation.LandscapeRight local function H()FadeInAndOutHalfDuration=2.5 FadeInAndOutBalance=.05 W=tick()end I=Z.Changed:connect(function(B)if B=="\067\117\114\114\101\110\116\083\099\114\101\101\110\079\114\105\101\110\116\097\116\105\111\110"then if y and Z.CurrentScreenOrientation==Enum.ScreenOrientation.Portrait or not y and Z.CurrentScreenOrientation~=Enum.ScreenOrientation.Portrait then I:disconnect()H()if y then HasFadedBackgroundInPortrait=true else HasFadedBackgroundInLandscape=true end end end end)ThumbstickFrame.Parent=B spawn(function()if game:IsLoaded()then H()else game.Loaded:wait()H()end end)end return Thumbstick
--
function Thumbstick:Enable()
	Enabled = true
	ThumbstickFrame.Visible = true
	local humanoid = MasterControl:GetHumanoid()
	enableAutoJump(humanoid)
end

function Thumbstick:Disable()
	Enabled = false
	if RevertAutoJumpEnabledToFalse then
		local humanoid = MasterControl:GetHumanoid()
		if humanoid then
			humanoid.AutoJumpEnabled = false
		end
	end
	ThumbstickFrame.Visible = false
	OnMoveTouchEnded()
end

function Thumbstick:Create(parentFrame)
	if ThumbstickFrame then
		ThumbstickFrame:Destroy()
		ThumbstickFrame = nil
		if OnTouchMovedCn then
			OnTouchMovedCn:disconnect()
			OnTouchMovedCn = nil
		end
		if OnTouchEndedCn then
			OnTouchEndedCn:disconnect()
			OnTouchEndedCn = nil
		end
		if OnRenderSteppedCn then
			OnRenderSteppedCn:disconnect()
			OnRenderSteppedCn = nil
		end
		if TouchActivateCn then
			TouchActivateCn:disconnect()
			TouchActivateCn = nil
		end
	end
	
	local ThumbstickSize = 40
	local ThumbstickRingSize = 58
	local MiddleSize = 13
	local MiddleSpacing = MiddleSize + 5
	local RadiusOfDeadZone = 2
	local RadiusOfMaxSpeed = 50	
	
	local screenSize = parentFrame.AbsoluteSize
	local isBigScreen = math.min(screenSize.x, screenSize.y) > 500
	if isBigScreen then
		ThumbstickSize = ThumbstickSize * 2
		ThumbstickRingSize = ThumbstickRingSize * 2
		MiddleSize = MiddleSize * 2
		MiddleSpacing = MiddleSpacing * 2
		RadiusOfDeadZone = RadiusOfDeadZone * 2
		RadiusOfMaxSpeed = RadiusOfMaxSpeed * 2
	end
	
	local color = Color3.fromRGB(255, 255, 255)
	
	local function layoutThumbstickFrame(portraitMode)
		if portraitMode then
			ThumbstickFrame.Size = UDim2.new(1, 0, .4, 0)
			ThumbstickFrame.Position = UDim2.new(0, 0, 0.6, 0)
		else
			ThumbstickFrame.Size = UDim2.new(1, 0, .5, 18)
			ThumbstickFrame.Position = UDim2.new(0, 0, 0.5, -18)
		end
	end
		
	ThumbstickFrame = Instance.new('Frame')
	ThumbstickFrame.Name = "DynamicThumbstickFrame"
	ThumbstickFrame.Active = false
	ThumbstickFrame.Visible = false
	ThumbstickFrame.BackgroundTransparency = 1.0
	ThumbstickFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
	layoutThumbstickFrame()

	StartImage = Instance.new("ImageLabel")
	StartImage.Name = "ThumbstickStart"
	StartImage.Visible = false
	StartImage.BackgroundTransparency = 1
	StartImage.Image = IMAGE_RING
	StartImage.AnchorPoint = Vector2.new(0.5, 0.5)
	StartImage.Parent = ThumbstickFrame
	
	EndImage = Instance.new("ImageLabel")
	EndImage.Name = "ThumbstickEnd"
	EndImage.Visible = false
	EndImage.BackgroundTransparency = 1
	EndImage.Image = IMAGE_DISK
	EndImage.ImageTransparency = 0.20
	EndImage.AnchorPoint = Vector2.new(0.5, 0.5)
	EndImage.Parent = ThumbstickFrame
	
	for i = 1, NUM_MIDDLE_IMAGES do
		MiddleImages[i] = Instance.new("ImageLabel")
		MiddleImages[i].Name = "ThumbstickMiddle"
		MiddleImages[i].Visible = false
		MiddleImages[i].BackgroundTransparency = 1
		MiddleImages[i].Image = IMAGE_DISK
		MiddleImages[i].ImageTransparency = MIDDLE_TRANSPARENCIES[i]
		MiddleImages[i].AnchorPoint = Vector2.new(0.5, 0.5)
		MiddleImages[i].Parent = ThumbstickFrame
	end
	
	local CameraChangedConn = nil
	local function onWorkspaceChanged(property)
		if property == 'CurrentCamera' then
			if CameraChangedConn then
				CameraChangedConn:Disconnect()
				CameraChangedConn = nil
			end
			local newCamera = workspace.CurrentCamera
			if newCamera then
				local size = newCamera.ViewportSize
				local portraitMode = size.X < size.Y
				layoutThumbstickFrame(portraitMode)
				CameraChangedConn = newCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
					size = newCamera.ViewportSize
					portraitMode = size.X < size.Y
					layoutThumbstickFrame(portraitMode)
				end)
			end
		end
	end
	workspace.Changed:Connect(onWorkspaceChanged)
	if workspace.CurrentCamera then
		onWorkspaceChanged('CurrentCamera')
	end
	
	local JumpTouchObject = nil
	local JumpTouchStartTime = nil
	local JumpTouchStartPosition = nil
	
	local MoveTouchObject = nil
	local MoveTouchStartTime = nil
	local MoveTouchStartPosition = nil
	
	local function doMove(direction)
		MasterControl:AddToPlayerMovement(-currentMoveVector)
		
		currentMoveVector = direction
		
		-- Scaled Radial Dead Zone
		local inputAxisMagnitude = currentMoveVector.magnitude
		if inputAxisMagnitude < RadiusOfDeadZone then
			currentMoveVector = Vector3.new()
		else
			currentMoveVector = currentMoveVector.unit*(1 - math.max(0, (RadiusOfMaxSpeed - currentMoveVector.magnitude)/RadiusOfMaxSpeed))
			currentMoveVector = Vector3.new(currentMoveVector.x, 0, currentMoveVector.y)
		end
		
		MasterControl:AddToPlayerMovement(currentMoveVector)
	end
	
	local TweenInAlphaStart = nil
	local TweenOutAlphaStart = nil
	OnRenderSteppedCn = RunService.RenderStepped:Connect(function(step)
		if TweenInAlphaStart ~= nil then
			local delta = tick() - TweenInAlphaStart
			local fadeInTime = (FadeInAndOutHalfDuration * 2 * FadeInAndOutBalance)
			ThumbstickFrame.BackgroundTransparency = 1 - FadeInAndOutMaxAlpha*math.min(delta/fadeInTime, 1)
			if delta > fadeInTime then
				TweenOutAlphaStart = tick()
				TweenInAlphaStart = nil
			end
		elseif TweenOutAlphaStart ~= nil then
			local delta = tick() - TweenOutAlphaStart
			local fadeOutTime = (FadeInAndOutHalfDuration * 2) - (FadeInAndOutHalfDuration * 2 * FadeInAndOutBalance)
			ThumbstickFrame.BackgroundTransparency = 1 - FadeInAndOutMaxAlpha + FadeInAndOutMaxAlpha*math.min(delta/fadeOutTime, 1)
			if delta > fadeOutTime  then
				TweenOutAlphaStart = nil
			end
		end
	end)
	
	local function layoutMiddleImages(startPos, endPos)
		local startDist = (ThumbstickSize / 2) + MiddleSize
		local dist = startDist
		local vector = endPos - startPos
		local totalDist = vector.magnitude - (ThumbstickSize / 2) - (ThumbstickRingSize / 2) - (MiddleSize / 2)
		local direction = vector.unit

		local distNeeded = dist + (MiddleSpacing * NUM_MIDDLE_IMAGES)		
		local spacing = 0
		
		if distNeeded > totalDist then
			spacing = MiddleSpacing
		else
			spacing = totalDist / NUM_MIDDLE_IMAGES
		end
			
		for i = 1, NUM_MIDDLE_IMAGES do
			local image = MiddleImages[i]
			local currentDist = startDist + (spacing * (i - 1))	
				
			if currentDist < totalDist then
				local pos = endPos - direction * currentDist
				
				image.Visible = true
				image.Position = UDim2.new(0, pos.X, 0, pos.Y)
				image.Size = UDim2.new(0, MiddleSize, 0, MiddleSize)
			else
				image.Visible = false
			end
		end
	end
	
	local function moveStick(pos)
		local startPos = Vector2.new(MoveTouchStartPosition.X, MoveTouchStartPosition.Y) - ThumbstickFrame.AbsolutePosition
		local endPos = Vector2.new(pos.X, pos.Y) - ThumbstickFrame.AbsolutePosition
		local relativePosition = endPos - startPos
		local length = relativePosition.magnitude
		local maxLength = ThumbstickFrame.AbsoluteSize.X
		
		length = math.min(length, maxLength)
		relativePosition = relativePosition*length
		
		EndImage.Position = UDim2.new(0, endPos.X, 0, endPos.Y)
		EndImage.Size = UDim2.new(0, ThumbstickSize, 0, ThumbstickSize)
		
		layoutMiddleImages(startPos, endPos)
	end
	
	-- input connections
	ThumbstickFrame.InputBegan:connect(function(inputObject)
		if inputObject.UserInputType ~= Enum.UserInputType.Touch or inputObject.UserInputState ~= Enum.UserInputState.Begin then
			return
		end
		if MoveTouchObject then
			if not JumpTouchObject then
				JumpTouchObject = inputObject
				JumpTouchStartTime = tick()
				JumpTouchStartPosition = inputObject.Position
			end
			return
		end
		
		MoveTouchObject = inputObject
		MoveTouchStartTime = tick()
		MoveTouchStartPosition = inputObject.Position
		local startPosVec2 = Vector2.new(inputObject.Position.X - ThumbstickFrame.AbsolutePosition.X, inputObject.Position.Y - ThumbstickFrame.AbsolutePosition.Y)

		StartImage.Visible = true
		StartImage.Position = UDim2.new(0, startPosVec2.X, 0, startPosVec2.Y)
		StartImage.Size = UDim2.new(0, ThumbstickRingSize, 0, ThumbstickRingSize)
		EndImage.Visible = true
		EndImage.Position = StartImage.Position
		EndImage.Size = UDim2.new(0, ThumbstickSize, 0, ThumbstickSize)
		
		if FadeInAndOutBackground then
			local playerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui")
			local hasFadedBackgroundInOrientation = false

			-- only fade in/out the background once per orientation
			if playerGui then
				if playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.LandscapeLeft or 
					playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.LandscapeRight then
						hasFadedBackgroundInOrientation = HasFadedBackgroundInLandscape
						HasFadedBackgroundInLandscape = true
				elseif playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.Portrait then
						hasFadedBackgroundInOrientation = HasFadedBackgroundInPortrait
						HasFadedBackgroundInPortrait = true
				end
			end

			if not hasFadedBackgroundInOrientation then
				FadeInAndOutHalfDuration = FADE_IN_OUT_HALF_DURATION_DEFAULT
				FadeInAndOutBalance = FADE_IN_OUT_BALANCE_DEFAULT
				TweenInAlphaStart = tick()
			end
		end
	end)
	
	OnTouchMovedCn = UserInputService.TouchMoved:connect(function(inputObject, isProcessed)
		if inputObject == MoveTouchObject then
			
			local direction = Vector2.new(inputObject.Position.x - MoveTouchStartPosition.x, inputObject.Position.y - MoveTouchStartPosition.y)
			if math.abs(direction.x) > 0 or math.abs(direction.y) > 0 then
				doMove(direction)
				moveStick(inputObject.Position)
			end
		end
	end)
	
	OnMoveTouchEnded = function()
		StartImage.Visible = false
		EndImage.Visible = false
		
		for i = 1, NUM_MIDDLE_IMAGES do
			MiddleImages[i].Visible = false
		end
		
		MoveTouchObject = nil
		
		MasterControl:AddToPlayerMovement(-currentMoveVector)
		currentMoveVector = Vector3.new(0,0,0)
	end

	--todo: remove this pcall when TouchTapInWorld is on for all platforms
	local success = pcall(function() 
		local function positionIntersectsGuiObject(position, guiObject)
			if position.X < guiObject.AbsolutePosition.X + guiObject.AbsoluteSize.X
				and position.X > guiObject.AbsolutePosition.X
				and position.Y < guiObject.AbsolutePosition.Y + guiObject.AbsoluteSize.Y
				and position.Y > guiObject.AbsolutePosition.Y then
				return true
			end
			return false
		end

		TouchActivateCn = UserInputService.TouchTapInWorld:connect(function(touchPos, processed)
			if not processed and Enabled and not IsAToolEquipped and positionIntersectsGuiObject(touchPos, ThumbstickFrame) then
				MasterControl:DoJump()
			end
		end)
	end)

	if not success then
		local function JumpIfTouchIsTap(startTime, startPosition, position)
			if (not IsAToolEquipped) and tick() - startTime < TOUCH_IS_TAP_TIME_THRESHOLD then
				if (position - startPosition).magnitude < TOUCH_IS_TAP_DISTANCE_THRESHOLD then
					MasterControl:DoJump()
				end
			end
		end
		
		OnTouchEndedCn = UserInputService.TouchEnded:connect(function(inputObject, isProcessed)
			if inputObject == MoveTouchObject then
				JumpIfTouchIsTap(MoveTouchStartTime, MoveTouchStartPosition, inputObject.Position) 
				OnMoveTouchEnded()
			elseif inputObject == JumpTouchObject then
				JumpIfTouchIsTap(JumpTouchStartTime, JumpTouchStartPosition, inputObject.Position)
				JumpTouchObject = nil
			end
		end)
	else
		OnTouchEndedCn = UserInputService.TouchEnded:connect(function(inputObject, isProcessed)
			if inputObject == MoveTouchObject then
				OnMoveTouchEnded()
			elseif inputObject == JumpTouchObject then
				JumpTouchObject = nil
			end
		end)
	end
	
	GuiService.MenuOpened:connect(function()
		if MoveTouchObject then
			OnMoveTouchEnded()
		end
		if JumpTouchObject then
			JumpTouchObject = nil
		end
	end)

	local playerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui")
	while not playerGui do
		LocalPlayer.ChildAdded:wait()
		playerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui")
	end

	local playerGuiChangedConn = nil
	local originalScreenOrientationWasLandscape = playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.LandscapeLeft or
													playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.LandscapeRight

	local function longShowBackground()
		FadeInAndOutHalfDuration = 2.5
		FadeInAndOutBalance = 0.05
		TweenInAlphaStart = tick()
	end

	playerGuiChangedConn = playerGui.Changed:connect(function(prop)
		if prop == "CurrentScreenOrientation" then
			if (originalScreenOrientationWasLandscape and playerGui.CurrentScreenOrientation == Enum.ScreenOrientation.Portrait) or
				(not originalScreenOrientationWasLandscape and playerGui.CurrentScreenOrientation ~= Enum.ScreenOrientation.Portrait) then
					playerGuiChangedConn:disconnect()
					longShowBackground()

					if originalScreenOrientationWasLandscape then
						HasFadedBackgroundInPortrait = true
					else
						HasFadedBackgroundInLandscape = true
					end
			end
		end
	end)
	
	ThumbstickFrame.Parent = parentFrame

	spawn(function()
		if game:IsLoaded() then
			longShowBackground()
		else
			game.Loaded:wait()
			longShowBackground()
		end
	end)
end

return Thumbstick
