Does anyone have an idea on why this doesnt put things in its workspace?

Essentially this is a car spawner and I was wondering why it works on an empty baseplate but not on a full map?

wait(3)
local replicatedstorage = game:GetService("ReplicatedStorage")
local guiEvent = replicatedstorage:FindFirstChild("GuiEvent")
local spawnCarEvent = replicatedstorage:FindFirstChild("SpawnCarEvent")
local spawnCarPart = game.Workspace.SpawnCarPart
local flag = true
local module = require(script.Parent.ModuleScript)
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(plr)
	wait(1)
	plr.PlayerGui:WaitForChild("MA's Car Spawner GUI").MainFrame.CarDisplay.Car1Display.CarName.Text = module.CarDesc1[1]
	plr.PlayerGui:WaitForChild("MA's Car Spawner GUI").MainFrame.CarDisplay.Car1Display.TextLabel.Text = module.CarDesc1[2]
	plr.PlayerGui:WaitForChild("MA's Car Spawner GUI").MainFrame.CarDisplay.Car2Display.CarName.Text = module.CarDesc2[1]
	plr.PlayerGui:WaitForChild("MA's Car Spawner GUI").MainFrame.CarDisplay.Car2Display.TextLabel.Text = module.CarDesc2[2]
end)

spawnCarEvent.OnServerEvent:Connect(function(plr,msg,car)
	local plrCar2 = plr.Name.. 'sCar2'
	local plrCar1 = plr.Name.. 'sCar1'
	if msg == "Part" then
		if game.Workspace:FindFirstChild(plr.Name..'sCar1') then
			wait(1)
			game.Workspace:FindFirstChild(plr.Name..'sCar1'):Destroy()
			local clone1 = replicatedstorage:WaitForChild(car.Name):Clone()
			clone1.Parent = game.Workspace
			clone1:MoveTo(Vector3.new(spawnCarPart.Position.X, 4.727,spawnCarPart.Position.Z))
			clone1.Name = plr.Name .. 'sCar1'
		elseif game.Workspace:FindFirstChild(plr.Name.. 'sCar2') then
			wait(1)
			game.Workspace:FindFirstChild(plr.Name.. 'sCar2'):Destroy()
			local clone1 = replicatedstorage:WaitForChild(car.Name):Clone()
			clone1.Parent = game.Workspace
			clone1:MoveTo(Vector3.new(spawnCarPart.Position.X, 4.727,spawnCarPart.Position.Z))
			clone1.Name = plr.Name .. 'sCar1'
		else
			wait(1)
			local clone1 = replicatedstorage:WaitForChild(car.Name):Clone()
			clone1.Parent = game.Workspace
			clone1:MoveTo(Vector3.new(spawnCarPart.Position.X, 4.727,spawnCarPart.Position.Z))
			clone1.Name = plr.Name .. 'sCar1'
		end
	end
end)

I don’t know, it’s terribly written, and you have a module in there, which means I have no idea how your module works. You need to explain how your module works.

1 Like

the module is for gui purpose and it doesnt have anything to do with the script itself. It basically runs from a local script where once a button is clicked it will send around the car selected and a msg (msg is just to verify its the right script) and it checks if theres already a car and if there is it will delete and spawn a new one but it wont spawn it doesnt have any errors.

I think there is a mistake, I don’t know how your car is built, but you will probably want to have some Main Part

clone1.MainPartName.CFrame = CFrame.new(spawnCarPart.Position.X, 4.727,spawnCarPart.Position.Z)

and otherwise, how high is your map? because the height there is set to 4.727, and if you spawn a car on a hill, it will spawn under it.