local player = game.Players.LocalPlayer
local button = script.Parent
local carFolder = ReplicatedStorage:FindFirstChild("CarSpawnFolder")
button.MouseButton1Click:Connect(function()
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
local oldCar = workspace:FindFirstChild(player.Name .. "_Car")
if oldCar then oldCar:Destroy() end
local carTemplate = carFolder and carFolder:FindFirstChild("Hondasion")
if carTemplate then
local newCar = carTemplate:Clone()
newCar.Name = player.Name .. "_Car"
for _, part in pairs(newCar:GetDescendants()) do
if part:IsA("BasePart") then part.Anchored = true end
end
newCar.Parent = workspace
newCar:SetPrimaryPartCFrame(rootPart.CFrame * CFrame.new(0, 8, -15))
for _, desc in pairs(newCar:GetDescendants()) do
if desc:IsA("LocalScript") or desc:IsA("Script") then
local carVal = desc:FindFirstChild("CarValue")
if carVal then carVal.Value = newCar end
desc.Disabled = true
desc.Disabled = false
end
end
task.wait(0.5)
for _, part in pairs(newCar:GetDescendants()) do
if part:IsA("BasePart") then part.Anchored = false end
end
end
end)```