Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i spawn a meshed car?

i'm trying to make a car shoot out across a road i've built, and that car is a mesh, but whenever the script runs, it just spawns a part, and i can't use MeshPart since i cannot specify the MeshId with scripts.

the result i'm looking for is a mesh car zooming through and killing the player when it's touched

anyway heres the script

local spawner = game.Workspace
local part = script.Parent
local partspawned = Instance.new("Part", workspace)

while true do
local car = game.Workspace.zoomy.Mesh --zoomy is the car i am trying to clone
wait(10)
partspawned:Clone(car)
car.Velocity = Vector3.new(0,0,-100)
car.Anchored = false
car.Position = part.Position
end

partspawned.Touched:Connect(function(hit)
 if game.Players:FindFirstChild(hit.Parent.Name) then
 hit.Parent.Humanoid:TakeDamage(math.huge)
end
end)

the meshId for the car is 1490852609 if anyones wondering

edit: changed the script a lil bit edit 2: i have big brained and quite possibly the script could work if i spawned a part, and grouped the mesh in the part

2 answers

It's not possible to instance a mesh but here is something that should help

local spawner = game.Workspace
local part = script.Parent
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid:// " -- Put your mesh id here.



while true do
local car = game.Workspace.zoomy.Mesh --zoomy is the car i am trying to clone
wait(10)
partspawned:Clone(car)
car.Velocity = Vector3.new(0,0,-100)
car.Anchored = false
car.Position = part.Position
end

partspawned.Touched:Connect(function(hit)
 if game.Players:FindFirstChild(hit.Parent.Name) then
 hit.Parent.Humanoid:TakeDamage(math.huge)
end
end)

ok nvm it works now lmao

while true do
wait(15) --spawns every 15 seconds
local car = Instance.new("Part", workspace) --creates part
local mesh = Instance.new("SpecialMesh", car) --creates the mesh inside the part
mesh.MeshId = "rbxassetid://1490852609"
mesh.TextureId = "rbxassetid://1490852626"
mesh.Scale = Vector3.new(1.3,1.3,1.3)
car.Position = script.Parent.Position --spawning place
car.Name = "car"
car.Anchored = false
car.Size = Vector3.new(9,6,20)
car.Velocity = Vector3.new(0,0,-150)
car.Material = Enum.Material.Ice 
car.Touched:Connect(function(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) then
		hit.Parent.Humanoid.Health = 0
	end
	end)
wait(4) --after 4 seconds it destroys the car
car:Destroy()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.