--Find if character aleady exists

if Player.Character~= nil then
	Character = Player.Character
	HRP = Character:WaitForChild("HumanoidRootPart")
	Humanoid = Character:WaitForChild("Humanoid")
end

function EnterStart(Type)
	if not EnterKeyDown then
		EnterKeyDown = true
		SwitchButtonType(Type)
		local i = 0
		local TilesX = 6
		local TileSize = 170.66667
		local NumberTiles = 36
		RingSprite.ImageColor3 = Color3.new(0.8,0.82,1)
		--Tell server we're trying to get in 
		Remotes.GetInStart:FireServer(AdornedSeat)
		--Play sprite sheet animation
		local TargetSeat = AdornedSeat
		local StartTime = elapsedTime()
		while EnterKeyDown and AdornedSeat do
			local TimeDelta = elapsedTime()-StartTime
			local FrameNum = math.floor( (TimeDelta/TimeToEnter)*NumberTiles + 0.5 )
			local X = FrameNum%6
			local Y = math.floor(FrameNum/6)
			RingSprite.ImageRectOffset = Vector2.new(X*TileSize,Y*TileSize)
			wait()
			print(X)
			--Get in the seat
			if TimeDelta >= TimeToEnter then
				ButtonImage.Visible = false
				Remotes.GetInSeat:FireServer(AdornedSeat)
				local n = 0
				repeat
					wait()
				until AdornedSeat == nil or n>20
				ButtonImage.Visible = true
				break
			end
		end
		--Tell server we are no longer getting in the seat 
		Remotes.GetInEnd:FireServer(TargetSeat)
		--Reset the button gui
		RingSprite.ImageRectOffset = Vector2.new(0,0)
		RingSprite.ImageColor3 = Color3.new(1,1,1)
	end
end
