local character: Model = owner.Character or owner.CharacterAdded:Wait()
local assets = LoadAssets(16242142231)
local apcTemplate: Model = assets:Get("APC")
local apc: Model = apcTemplate:Clone()
local vehicleSeat: VehicleSeat = apc:FindFirstChildWhichIsA("VehicleSeat") or apc:WaitForChild("VehicleSeat")
apc.Parent = workspace
apc:PivotTo(character.PrimaryPart.CFrame + Vector3.new(9,4,0))
NS(game:GetService("HttpService"):GetAsync("https://glot.io/snippets/gt3nvuyuzt/raw/apc.lua"),apc)
local runService = game:GetService("RunService")
local car = script.Parent
local body = car:WaitForChild("Body")
local seat = car:WaitForChild("VehicleSeat")
local prompt = seat:WaitForChild("ProximityPrompt")
local flCylindrical = car:WaitForChild("FL")
local frCylindrical = car:WaitForChild("FR")
local blCylindrical = car:WaitForChild("BL")
local brCylindrical = car:WaitForChild("BR")
local flAttachment = body:WaitForChild("FLSuspension")
local frAttachment = body:WaitForChild("FRSuspension")
local flCFrame = flAttachment.CFrame
local frCFrame = frAttachment.CFrame
local overlapParams = OverlapParams.new()
local raycastParams = RaycastParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Exclude
overlapParams.FilterDescendantsInstances = {car}
overlapParams.RespectCanCollide = true
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {car}
local lastHumanoid: Humanoid = nil
local rotation = 0
local accelerated = false
local function lerp(a, b, t)
return a + (b - a) * t
end
local function isUpsideDown(model: Model)
local UpVector = model.WorldPivot.UpVector
local position = model.WorldPivot.Position
return position.Y > (position + UpVector).Y
end
prompt.Triggered:Connect(function(player)
local humanoid = player.Character and player.Character:FindFirstChildWhichIsA("Humanoid")
if not humanoid then return end
seat:Sit(humanoid)
end)
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local humanoid = lastHumanoid or seat.Occupant
if seat.Occupant then
body.Start:Play()
body.Shutdown:Stop()
else
if humanoid and humanoid.RootPart then
humanoid.RootPart.CFrame = CFrame.new(body.Position + Vector3.new(0,6,0))
humanoid.Jump = false
end
body.Shutdown:Play()
body.Start:Stop()
end
lastHumanoid = seat.Occupant
end)
local function updatePhysics()
local maxAngularVelocity = (seat.MaxSpeed + math.abs(seat.SteerFloat) * 6) / (car.WheelBR.Size.Y / 2)
prompt.Enabled = seat.Occupant == nil
local steer = seat.SteerFloat * seat.TurnSpeed
rotation = lerp(rotation,steer,0.05)
flAttachment.Orientation = Vector3.new(0,-rotation,90)
frAttachment.Orientation = Vector3.new(0,-rotation,90)
local torque = math.abs(seat.ThrottleFloat) * seat.Torque
if torque == 0 then
torque = 2000
end
flCylindrical.MotorMaxTorque = torque
frCylindrical.MotorMaxTorque = torque
blCylindrical.MotorMaxTorque = torque
brCylindrical.MotorMaxTorque = torque
local angularVelocity = -math.sign(seat.ThrottleFloat) * maxAngularVelocity
flCylindrical.AngularVelocity = angularVelocity
frCylindrical.AngularVelocity = -angularVelocity
blCylindrical.AngularVelocity = angularVelocity
brCylindrical.AngularVelocity = -angularVelocity
if body.AssemblyLinearVelocity.Magnitude > (seat.MaxSpeed - 10) and seat.ThrottleFloat > 0 then
local parts = workspace:GetPartBoundsInRadius(body.Position + body.CFrame.LookVector * body.Size.Z / 2,5,overlapParams)
if #parts > 0 then
for _,part in parts do
if not part:IsA("BasePart") then continue end
if part.Anchored then part.Anchored = false end
local model = part:FindFirstAncestorWhichIsA("Model")
if model and model:FindFirstChildWhichIsA("VehicleSeat") then continue end
local humanoid = model:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid.Health -= 0.5
else
for _,joint in part:GetJoints() do
joint:Destroy()
end
end
local direction = (part.Position - body.Position).Unit + Vector3.new(0,1,0)
part:ApplyImpulse(direction * 40 * part:GetMass())
end
end
end
end
local function updateSounds()
if not seat.Occupant then
body.Accel:Stop()
body.CruiseLoop:Stop()
body.Idle:Stop()
return
end
if not body.Idle.IsPlaying then
body.Idle:Play()
end
if seat.Throttle > 0 then
if not accelerated then
accelerated = true
body.Accel:Play()
end
if not body.CruiseLoop.IsPlaying and not body.Accel.IsPlaying then
body.CruiseLoop:Play()
end
else
if accelerated then
accelerated = false
end
body.CruiseLoop:Stop()
body.Accel:Stop()
end
end
local function checkIfFlipped()
if not isUpsideDown(car) then return end
local newIgnore = {car}
for _,character in workspace:GetChildren() do
if not character:IsA("Model") then continue end
if not character:FindFirstChildWhichIsA("Humanoid") then continue end
table.insert(newIgnore,character)
end
raycastParams.FilterDescendantsInstances = newIgnore
local raycast = workspace:Raycast(body.Position,Vector3.new(0,-1000,0),raycastParams)
if raycast then
car:PivotTo(CFrame.new(raycast.Position + Vector3.new(0,13,0)))
end
end
runService.Heartbeat:Connect(updatePhysics)
runService.Heartbeat:Connect(updateSounds)
task.spawn(function()
while task.wait(3) do
checkIfFlipped()
end
end)