Vehicle wont spawn if bought

im trying to make a vehicle spawner using proximity when players bought it with cash, it would deduct the cash value but the vehicle wont spawn. - im new to lua

promixity script:

local car = game.ReplicatedStorage.Wave125i
script.Parent.Triggered:Connect(function(player)
local Cash = player.Cash
if Cash.Value >= 200 then
Cash.Value -= 200
local Clone = car:Clone()

end

end)

serverscript:

game.ReplicatedStorage.car.OnServerEvent:Connect(function(player)
local Workspace = game:GetService(“Workspace”)
if player.Cash.Value >= 200 then
player.Cash.Value = player.Cash.Value - 200
game.ReplicatedStorage.Wave125i:Clone().Parent = Workspace:FindFirstChild(“vehiclespawn”)
end
end)

1 Like

Based on what I’ve interpreted of your code you may not have positioned it after cloning.
Here’s a fix, assuming your vehicle is a model and vehiclespawn is a BasePart of some sort (not tested):

local vehicleSpawn = workspace:FindFirstChild(“vehiclespawn”)
game.ReplicatedStorage.car.OnServerEvent:Connect(function(player)
    if player.Cash.Value >= 200 then
        player.Cash.Value = player.Cash.Value - 200
        local clonedCar = game.ReplicatedStorage.Wave125i:Clone()
        clonedCar.Parent = vehicleSpawn
        clonedCar:MoveTo(vehicleSpawn.Position)
    end
end)
1 Like

yes, the vehicle is a model and the vehicle is part

1 Like

no errors, still doesn’t work :frowning:

Have you tried adding an offset to see if that will work?
clonedCar:MoveTo(vehicleSpawn.Position + Vector3.new(0, 10, 0))

Otherwise, look for if the clone appears in workspace or not.

tried adding offset in it but still it wont work, upon checking the clone doesnt appears in the workspace

Whoops. Overlooked the proximity script:

New proximity script:

script.Parent.Triggered:Connect(function(player)
    game.ReplicatedStorage.car:FireServer()
end

Wrote this in about 30 seconds, but this should fix it.
Any additional modifications shouldn’t be too hard to do.

1 Like

i managed to fix it, thank you!

1 Like

No problem. Be sure to mark it as the solution! :slight_smile: