local e=Home:WaitForChild("\067\111\110\102\105\103\117\114\097\116\105\111\110")local Q=e:WaitForChild("\083\119\105\110\103\080\111\119\101\114")local function o(e,Q)if e then e.CustomPhysicalProperties=PhysicalProperties.new(Q,e.Friction,e.Elasticity)end end GetAllDescendants=function(e,Q)Q(e)for e,o in next,e:GetChildren()do GetAllDescendants(o,Q)end end local function H(e,Q)GetAllDescendants(Q,function(e)if e and(e.Parent and e:IsA("\066\097\115\101\080\097\114\116"))then o(e,density)end end)end local function Z(e)if e.Occupant then local o=e.Throttle local Z=e:WaitForChild("\066\111\100\121\070\111\114\099\101")if o==1 then Z.Force=(e.CFrame.lookVector*Q.Value)*100 elseif o==-1 then Z.Force=(e.CFrame.lookVector*Q.Value)*-100 else Z.Force=Vector3New()end delay(.2,function()Z.Force=Vector3New()end)if CurrentOccupant==nil then CurrentOccupant=e.Occupant H(0,CurrentOccupant.Parent)end elseif CurrentOccupant then H(.7,CurrentOccupant.Parent)CurrentOccupant=nil end end SwingSeat1.Changed:connect(function()Z(SwingSeat1)end)SwingSeat2.Changed:connect(function()Z(SwingSeat2)end)

local Configuration = Home:WaitForChild("Configuration")
local SwingPower = Configuration:WaitForChild("SwingPower")

local function SetPhysicalProperties(Part,Density)
	if Part then
		Part.CustomPhysicalProperties = PhysicalProperties.new(Density,Part.Friction,Part.Elasticity)
	end
end

GetAllDescendants = function(instance, func)
	func(instance)
	for _, child in next, instance:GetChildren() do
		GetAllDescendants(child, func)
	end
end

local function SetCharacterToWeight(ToDensity,Char)
	GetAllDescendants(Char,function(d)
		if d and d.Parent and d:IsA("BasePart") then
			SetPhysicalProperties(d,density)
		end
	end)
end

local function OnSeatChange(Seat)
	if Seat.Occupant then
		local CurrentThrottle = Seat.Throttle
		local BodyForce = Seat:WaitForChild("BodyForce")
		
		-- Adjust swing when interacted
		if CurrentThrottle == 1 then
			BodyForce.Force = Seat.CFrame.lookVector * SwingPower.Value * 100
		elseif CurrentThrottle == -1 then
			BodyForce.Force = Seat.CFrame.lookVector * SwingPower.Value * -100
		else
			BodyForce.Force = Vector3New()
		end
		
		delay(0.2,function()
			BodyForce.Force = Vector3New()
		end)
		
		-- Make the character weightless for the swing to behave correctly
		if CurrentOccupant == nil then
			CurrentOccupant = Seat.Occupant
			SetCharacterToWeight(0,CurrentOccupant.Parent)
		end
		
	elseif CurrentOccupant then
		-- Set the character's weight back
		SetCharacterToWeight(0.7,CurrentOccupant.Parent)
		CurrentOccupant = nil
	end
end

SwingSeat1.Changed:connect(function()
	OnSeatChange(SwingSeat1)
end)

SwingSeat2.Changed:connect(function()
	OnSeatChange(SwingSeat2)
end)
