SegwayObject.Changed:connect(function()if SegwayObject.Value~=nil and SegwayObject.Value.Parent then if UserInputService.VREnabled then Camera.CameraType="\083\099\114\105\112\116\097\098\108\101"else Camera.CameraType="\070\111\108\108\111\119"end Lights=SegwayObject.Value:WaitForChild("\076\105\103\104\116\115")Notifiers=SegwayObject.Value:WaitForChild("\078\111\116\105\102\105\101\114\115")Character=Player.Character Humanoid=Character:WaitForChild("\072\117\109\097\110\111\105\100")PlayerGui=Player.PlayerGui SitListener=Humanoid.Seated:connect(function()Hopoff(Character)end)JumpListener=UserInputService.JumpRequest:connect(function()Hopoff(Character)end)ConfigLights:FireServer(0,"\067\121\097\110",true,"\078\101\111\110",Lights,Notifiers)CheckMobile()CheckVR()IsOnSegway=true end end)SetGuiButtons()while(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:wait()do CastToGround()if SegwayObject.Value and(SegwayObject.Value.Parent and(SeaterObject.Value and(Thruster.Value and TiltMotor.Value)))then Accelerate()Sound()Tilt()UpdateVRPos()elseif IsOnSegway then IsOnSegway=false UpdateCharTrans(0,0)end end

SegwayObject.Changed:connect(function()
	if SegwayObject.Value ~= nil and SegwayObject.Value.Parent then
		if UserInputService.VREnabled then
			Camera.CameraType = "Scriptable"
		else
			Camera.CameraType = "Follow"
		end
		Lights = SegwayObject.Value:WaitForChild("Lights")
		Notifiers = SegwayObject.Value:WaitForChild("Notifiers")
		Character = Player.Character
		Humanoid = Character:WaitForChild("Humanoid")
		PlayerGui = Player.PlayerGui
		SitListener = Humanoid.Seated:connect(function()Hopoff(Character)end)
		JumpListener = UserInputService.JumpRequest:connect(function()Hopoff(Character)end)
		ConfigLights:FireServer(0,"Cyan",true,"Neon",Lights,Notifiers)
		CheckMobile()
		CheckVR()
		IsOnSegway = true
	end
end)

SetGuiButtons()

while game:GetService("RunService").RenderStepped:wait() do
	
	-- Update segway's bottom direction
	CastToGround()
	
	if SegwayObject.Value and SegwayObject.Value.Parent and SeaterObject.Value and Thruster.Value and TiltMotor.Value then
	
		-- Move segway
		Accelerate()
			
		-- Change sound of segway
		Sound()
			
		-- Tilts the segway
		Tilt()
		
		UpdateVRPos()
	
	elseif IsOnSegway then
		IsOnSegway = false
		UpdateCharTrans(0,0)
	end
	
end