Hi all.
I'm trying to make a game where cars will drive along a road and the player must run between them without getting hit.
To do this, I have 2 types of car parts in server storage. One scripted to move right and one to move left.
A script stored within ServerScriptService is used to clone these cars then make the copy a child of a part beside the road to act as a spawn point.
My issue is I have added an additional road, a duplicate of the road model I already have including the spawn blocks. However, the cars only spawn on the original road, not the duplicated one as well. I was wondering how I would go about doing this to have the cars appear at all spawn points. Would I need additional models or cars?
For Clarification. I made the cars spawn on the bottom road but I also want them to spawn on the road above at the same time. I assumed duplicating the road model would work as the path to it would be the same. What should I do instead?
I made a project that spawn the same object from ReplicatedStorage to different spawn part locations. I just put this script inside each of the spawn parts in Workspace.
local Bear = game.ReplicatedStorage.Bear local spawner = script.Parent while true do local Clone = Bear: Clone() Clone.Dummy.UpperTorso.CFrame = spawner.CFrame Clone.Parent = workspace wait(10) Clone:remove() wait(0) end
For your project, I see that you use a single script to spawn the cars. Maybe you can use this sample code and alter it to work for your project:
local spawners = game.Workspace.Spawns -- folder or model of the spawn parts local car = game.ReplicatedStorage.Car local Clone1 = car:Clone() local Clone2 = car:Clone() local Clone3 = car:Clone() local Clone4 = car:Clone() --set a PrimaryPart because models don't have Position or CFrame. Pick a part inside your model. I just name it to PrimaryPart to make it easier to notice. Clone1.PrimaryPart = Clone1.primarypart Clone2.PrimaryPart = Clone2.primarypart Clone3.PrimaryPart = Clone3.primarypart Clone4.PrimaryPart = Clone4.primarypart -- create a loop while true do wait (1) -- wait for everything to load ... can remove if you want or adjust -- put the car into the world Clone1.Parent = workspace Clone2.Parent = workspace Clone3.Parent = workspace Clone4.Parent = workspace -- bring the model to the spawner's CFrame/Position Clone1.PrimaryPart.CFrame = spawners.spawn1.CFrame + Vector3.new(0,0,0) Clone2.PrimaryPart.CFrame = spawners.spawn2.CFrame + Vector3.new(0,0,0) Clone3.PrimaryPart.CFrame = spawners.spawn3.CFrame + Vector3.new(0,0,0) Clone4.PrimaryPart.CFrame = spawners.spawn4.CFrame + Vector3.new(0,0,0) wait(5) -- wait how many seconds till it goes disappear Clone1.Parent = nil Clone2.Parent = nil Clone3.Parent = nil Clone4.Parent = nil end