Why won't my vehicles stay on the map after cloning?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Clone vehicle(s) from ServerStorage to a folder in workspace and move it to position on a map.

  2. What is the issue? Vehicles disappear after a second.

  3. What solutions have you tried so far? I have looked everywhere and any solution I found has not worked. I can’t figure out why my vehicles aren’t cloning to the spots indicated on the map.

local maps = game.ServerStorage.Maps:GetChildren()
-- Inserting random map
local function choosenMap()
local mapClone = maps[math.random(1,#maps)]:Clone()
mapClone.Parent = game.Workspace.CurrentMap
wait(15)
end


local parts = game.Workspace.CurrentMap.Map:GetChildren()
local cars = game.ServerStorage.Cars:GetChildren()
local function carSpawner()
for i, object in pairs(parts)do
if(object.Name == "SpawnSpot")then
local clone = cars[math.random(1,#cars)]:Clone()
clone.Parent = game.Workspace.Cars
clone:MoveTo(object.Position)
object:Destroy()
end
end
end

Not sure what the issue is, any help is great. I have a city map in workspace, it is the main map the character uses. The added maps are tracks and I can’t get the vehicles to spawn onto those maps. From the looks of it the script works, however a split second later the cars disappear from the map. The only other script I have in the game is for the camera. Car or not it will do this to any object.

Is there any anchored floor part(for example a baseplate). Maybe the cars are falling off the map if there is nothing beneath them.

If the player is cloning in a map, the server wouldn’t ‘see’ the part. IDK if this is what is happening though.

I have not done any map cloning before.

1 Like

All parts are anchored. I thought that was the issue as well but I anchored through properties and double-checked it with a script. The script is also in ServerScriptService. I clone from there and add it to the workspace. I’ve been stuck on this for a solid week. Can’t seem to pinpoint the issue.

try

if game.ServerStorage:FindFirstChild("VehicleName") then
      carSpawner()
end
1 Like

Thank you for the help. However I just “fixed” it. Had a random thought to change the position of the map closer to the main map, and for whatever reason carSpawner() worked. I’m not sure why but solution found…

It’s possible that you were moving the model to a location under the map and/or it was simply falling through the map. Usually when you clone instances onto a map you want to raise the position at which you move them to by several studs.

1 Like

Doesn’t seem like that was the problem. Using MoveTo() would help prevent that. I think the issue was the position of the map being too far from the origin…might have to make my maps individual servers rather than having it all in one.

Was the map cloned below the value of the “FallenPartsDestroyHeight” property of the “Workspace” object? Because if so then it would have been destroyed along with the vehicle you were attempting to spawn there.

https://developer.roblox.com/en-us/api-reference/property/Workspace/FallenPartsDestroyHeight

1 Like

Thank you! That identified the issue perfectly and led me to a few posts mentioning that. The main map was at the origin and the maps cloning in were too far based on the property you mentioned, thus making it hard to spawn or move objects to that position without issues. After changing the property everything worked.