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)
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)