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