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