Hi, I have made a script that goes to a spawner for crates but when I try to use it it spawns all the crates in one location stacked on each other. My script is short and simple but I just need help trying to figure out how to make them spawn in different locations each time. Here is the script and I have only two spawners with the same script since I am just testing:
local Part = game.ReplicatedStorage.crate1
local spawner = script.Parent
while true do
local Clone = Part:Clone()
Clone.Parent = workspace
wait(48)
end
First off, if you want to spawn them on the spawners, you can use math.random (if you only want to have two) and you could say if randomNumber == 1 then and then spawn it to your spawner, and then use elseif for the other crates. (Probably a slow way to do it, but seemed the simplest to me)
You could have a bunch of spawners around the map in a folder and do this:
local Spawners = game.Workspace.Spawners:GetChildren()
local Coin = game.ServerStorage:WaitForChild("Coin")
function SpawnCoin()
local NewCoin = Coin:Clone()
local CoinSpawn = Spawners[math.random(1, #Spawners)]
NewCoin.CFrame = CoinSpawn.CFrame
NewCoin.Parent = workspace
end
while true do
SpawnCoin()
wait(1)
end
Would I put the script to the folder or into the spawners
You would put the script in ServerScriptService and have parts in the folders:
You could make a box as a spawn area then use some math to find get random spots inside of the box
Wow thank you that works so well I just doctored up the script to fit my needs and kaboom it works