Ello! Need a little help.
Basically, I need to find the SelectedCar (which I already defined) and then get it and define it under “Car”. What’s confusing here is SelectedCar is the car model name, not the path. Now I tried to define SelectedCar with the path of the car, didn’t work. How would I have Car give the path of the selectedcar even though SelectedCar is a string?
Btw, the car is at the path game.SeverStorage.Car_Mustang. Making Car the path of the car wouldn’t work as there are mutliple cars.
script.Parent.MouseButton1Up:Connect(function(player)
local SelectedCar = game.StarterGui["car spawn"].Main.VehicleInfo.Selected.Value
local Car = SelectedCar
local CloneCar = Car:Clone()
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}
CloneCar.Parent = game.Workspace
CloneCar.PrimaryPart = CloneCar.Primary
CloneCar:SetPrimaryPartCFrame(CFrame.new(PossibleSpawns[math.random(1, #PossibleSpawns)]))
game.ReplicatedStorage.PlayerSpawnedCar:FireServer(player)
script.Parent.Parent.Enabled = false
end)
You should be spawning the car on the server instead of the client. Currently, you are cloning and spawning the car on the client, which won’t replicate to other users and could cause some other issues.
Also, don’t use StarterGui to get GUI values, as that is static. Use the LocalPlayer’s PlayerGui and get the GUI and other objects you need there.