I’m looking at making a game where players can practice around for a few minutes on a racetrack before I set them up on the starting line to go race. Rather than deleting the car I’ve spawned them in and spawn a new car, I’m setting the CFrame of their current car & anchoring the tires / vehicleseat to prevent movement. This has the side effect however of preserving their previous momentum, such that when the race starts, their car will jolt forward with it’s previous speed.
Here is the current code I’m using for this task:
local Players = game:GetService("Players")
for index, p in pairs(Players:GetChildren()) do
local cars = workspace.Cars
local currentCar = cars:FindFirstChild(p.Name.."Car")
if currentCar ~= nil then
local track = workspace:WaitForChild("Track")
currentCar:SetPrimaryPartCFrame(track.StartSpots:FindFirstChild("P"..curCar).CFrame)
curCar = curCar + 1
for index, child in pairs(currentCar:GetChildren()) do
if child:IsA("Part") or child:IsA("WedgePart") or child:IsA("VehicleSeat") then
PhysicsService:SetPartCollisionGroup(child, playersno)
if child.Name == "Tire" or child.Name == "VehicleSeat" then
child.Anchored = true
end
end
end
end
end
Here’s also a video of what happens:
So far, I haven’t been able to really think of what to do to stop this from happening, hence my turning to the forum for possible suggestions.