Auto Swinging Script:
local RunService = game:GetService("RunService")
local CollectionService = game:GetService("CollectionService")
local Players = game:GetService("Players")
local swing = script.Parent
local swing2 = swing.Swing2
local swingSeat2 = swing.SwingSeat2
local bodyForce2 = swingSeat2:FindFirstChild("BodyForce")
if not bodyForce2 then
bodyForce2 = Instance.new("BodyForce")
bodyForce2.Parent = swingSeat2
end
local vector3New, clamp, sin = Vector3.new, math.clamp, math.sin
local swingPower = 3
local maxForce = 500
local swingSpeed = 3
local autoTime = 0
local currentOccupant = nil
local function setPhysicalProperties(part, density)
if part then
part.CustomPhysicalProperties = PhysicalProperties.new(density, part.Friction, part.Elasticity)
end
end
local function setCharacterToWeight(toDensity, characterModel)
for _, desc in pairs(characterModel:GetDescendants()) do
if desc:IsA("BasePart") then
setPhysicalProperties(desc, toDensity)
end
end
end
local function applySwingForce(part, throttle)
local force = part.CFrame.LookVector * swingPower * 10 * throttle
local clampedForce = Vector3.new(
clamp(force.X, -maxForce, maxForce),
clamp(force.Y, -maxForce, maxForce),
clamp(force.Z, -maxForce, maxForce)
)
return clampedForce
end
local function seatHumanoid(character, seat)
local humanoid = character:FindFirstChildOfClass("Humanoid")
local root = character:FindFirstChild("HumanoidRootPart")
if humanoid and root and not seat.Occupant then
humanoid.Sit = true
end
end
local function onSeat(seat)
local occupant = seat.Occupant
local bodyForce = seat:FindFirstChild("BodyForce")
if not bodyForce then return end
if occupant then
local throttle = math.max(0, seat.Throttle)
bodyForce.Force = applySwingForce(seat, throttle)
delay(0.2, function()
bodyForce.Force = vector3New(0, 0, 0)
end)
if not currentOccupant then
currentOccupant = occupant
local character = currentOccupant.Parent
seatHumanoid(character, seat)
setCharacterToWeight(0.0001, character)
end
end
end
RunService.Heartbeat:Connect(function(dt)
autoTime = autoTime + dt
local autoThrottle = math.sin(autoTime * swingSpeed)
bodyForce2.Force = applySwingForce(swingSeat2, autoThrottle)
end)