local function A(A,N,E,I,e,s,W)spawn(function()for I=0,1,1/(I/.03)do local s=N*(1-I)+E*I if e=="\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121"then A.AngularVelocity=s/100 end wait()end if e=="\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121"then A.AngularVelocity=E/100 end if s then s()end end)end local function N()A(FerrisMotor,FerrisMotor.AngularVelocity,WheelSpeed.Value,StartUpTime,"\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121")wait(StartUpTime+WheelMaxRideTime.Value)A(FerrisMotor,FerrisMotor.AngularVelocity*100,0,StartUpTime,"\065\110\103\117\108\097\114\086\101\108\111\099\105\116\121",function()IsMoving=false end)end local function E(A)if A.Occupant and IsMoving==false then IsMoving=true N()end end for A=1,#AllBaskets,1 do local N=AllBaskets[A]for A,N in pairs(N:GetChildren())do if N and N:IsA("\083\101\097\116")then table.insert(BasketSeats,N)end end end

local function TweenNumber(Object,FromNum,ToNum,Duration,ValueType,EndFunction,StartCFrame)
	spawn(function()
		for i=0,1,1/(Duration/0.03) do
			
			local NewN = FromNum * (1-i) + ToNum * i
			
			if ValueType == "AngularVelocity" then
				Object.AngularVelocity = NewN/100
			end
			
			wait()
		end
		
		if ValueType == "AngularVelocity" then
			Object.AngularVelocity = ToNum/100
		end
			
		if EndFunction then
			EndFunction()
		end
	end)
end

local function StartWheel()
	
	-- Tween the spin speed for the wheel
	TweenNumber(FerrisMotor,FerrisMotor.AngularVelocity,WheelSpeed.Value,StartUpTime,"AngularVelocity")
	
	wait(StartUpTime+WheelMaxRideTime.Value)
	
	-- Tween the spin speed for the wheel
	TweenNumber(FerrisMotor,FerrisMotor.AngularVelocity*100,0,StartUpTime,"AngularVelocity",function() IsMoving = false end)
end

local function DetectPlayer(Seat)
	if Seat.Occupant and IsMoving == false then
		IsMoving = true
		StartWheel()
	end
end

for i=1, #AllBaskets do
	local Basket = AllBaskets[i]
	
	for _,k in pairs(Basket:GetChildren()) do
		if k and k:IsA("Seat") then
			table.insert(BasketSeats,k)
		end
	end
end
