The SelectedCar isn’t nil when you print it. The button is a client script that fires a remote event saying what car it is to spawn and then a server script takes that and spawns that car.
Client (Button):
script.Parent.MouseButton1Up:Connect(function(player)
local SelectedCar = game.ReplicatedStorage.CarSystem.SelectedCar.Value
print(SelectedCar)
game:GetService("ReplicatedStorage").VehicleSpawnRequest:FireServer(SelectedCar)
end)
Server (On Event Fire):
local RS = game:GetService("ReplicatedStorage")
RS.VehicleSpawnRequest.OnServerEvent:Connect(function(SelectedCar, player)
local Car = SelectedCar
local CloneCar = Car:Clone(player)
local Position1 = game.Workspace["Civilian Spawn"].CarSpots.S1.Position
local Position2 = game.Workspace["Civilian Spawn"].CarSpots.S2.Position
local Position3 = game.Workspace["Civilian Spawn"].CarSpots.S3.Position
local Position4 = game.Workspace["Civilian Spawn"].CarSpots.S4.Position
local Position5 = game.Workspace["Civilian Spawn"].CarSpots.S5.Position
local PossibleSpawns = {Position1, Position2, Position3, Position4, Position5}
if Car then
else
print("Car not selected")
end
CloneCar.Parent = game.Workspace.Vehicles
CloneCar:SetPrimaryPartCFrame(CFrame.new(PossibleSpawns[math.random(1, #PossibleSpawns)]))
end)