-- Must have hopped on a segway

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