how to make a spawner. So that when you press the button, the model spawns in this place that I left in roblox studio? Help pls
COMMUNITY QUESTION
How to make a spawner so that when you press the button, the model spawns?
1 answer
Here is a little example, it works but it has no debounce and other stuff, it's just to show you how it works. 'carModel' is object we will be cloning when the spawner is clicked.
local spawner = "Button you want to press"
local clickDetector = spawner.ClickDetector
local carModel = workspace.Car -- Example object you want to clone
clickDetector.MouseClick:Connect(function() -- When cd is clicked
local newCar = carModel:Clone() -- Clone the car
newCar.Parent = workspace -- Set it's parent
end)
To spawn the car in some points you will need to create the point:
local spawnPoint = workspace.SpawnPoints -- example
local spawnPointsCFrame = spawnPoints.CFrame -- cframe of spawn points
local modelPrimaryPart = car.PrimaryPart -- If you want to move model, you need it's primary part (it's in properties of the model), if it's just a part then you just set part.CFrame
modelPrimaryPart.CFrame = spawnPointsCFrame
Again this is example, this script is not perfect but you can see how it works.
This discussion is preserved as it was. New answers, comments, and votes are closed.
