#Help, with spawning a car

1 messages · Page 1 of 1 (latest)

kindred sigil
#
-- ServerScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local Vehicles = ServerStorage.Vehicle_Storage.Civilian:GetChildren()

local DataStoreModule = require(game.ServerStorage.SDM)

local BuyRemote = ReplicatedStorage.CarRemotes:WaitForChild("Buy")

local Car_Spawns = workspace.Vehicle_Spawns.Citizen_Spawns:GetChildren()


BuyRemote.OnServerEvent:Connect(function(player, CarName, CarPrice)
    if player == nil then return end
    local dataStore = DataStoreModule.find("Stats", player.UserId)
    if dataStore == nil then return end
    if dataStore.State ~= true then return end
    for _, v in pairs(Vehicles) do
        local Spawnz = Car_Spawns[math.random(1, #Car_Spawns)]
        
        local BoughtCar = CarPrice
        
        if dataStore.Value.Bank >= tonumber(CarPrice) then
            v:Clone()
            v.Parent = Spawnz
        end
    end
end)

What I am trying to achieve is spawning a car with the same name as CarName

#

Help, with spawning a car[SOLVED]