-------------------
---[[Functions]]---
-------------------



local function UpdateSpeedometer()
	
	if Humanoid.SeatPart ~= nil and Humanoid.SeatPart.Parent:FindFirstChild("Stats") then
		Gui.Enabled = true
		
		local Cached_Magnitude = Char.Head.Velocity.magnitude

		--print(Char.Humanoid.SeatPart.Parent["Stats"].MaxSpeed.Value)
		
		--print(math.ceil())
	
		
		Pointer.Rotation = ( 180 / ( Humanoid.SeatPart.Parent["Stats"].MaxSpeed.Value / ((Cached_Magnitude)*1.62) ) ) ---OLD 1.8
		--print(math.abs(90 - ((Cached_Magnitude)*1.8))/45)
		Pointer.Arc.Size = UDim2.new(4.5 +(math.abs(90 - Pointer.Rotation)/45),0,0.5,0)
		
		Board.Speed.Text = math.floor((Cached_Magnitude)*1.62).." KM/H" ---OLD 1.8
		
		---Changing fov based on speed
		workspace.Camera.FieldOfView = 70 + ((Cached_Magnitude)*0.1)
		
	else
		Gui.Enabled = false
		
		if script.Parent.Parent.Parent:FindFirstChild("TouchGui") then
			script.Parent.Parent.Parent["TouchGui"].Enabled = true
			script.Parent.Parent.MobileControls.Visible = false
			script.Parent.Parent.PCHandbrake.Visible = false
		end
		
	end
end

RunService.Heartbeat:Connect(UpdateSpeedometer)
