Can you explain how I can edit it and get what I want? I don’t really see what to do… for the Spawn1, etc, what do I put, and make it that? A part, a Folder?
local spawncframes = {CFrame.new(699.21, 30.062, -5415.25), CFrame.new(684.67, 30.062, -5435.845)}
local rand = math.random(1, #spawncframes)
local coin = game.ServerStorage:WaitForChild("Coin")
while task.wait(10) do
local coinclone = coin:Clone()
coinclone.CFrame = spawncframes[rand]
coinclone.Parent = workspace
end
If you still don’t get it then I can’t help.
What script are you using? How is everything organised in the explorer window?
Because the user who replied decided to pick specified CFrames. Terrible method of doing it.
Here’s a perfect method on how to make your coins spawn in random positions.
That right there is a module called ZonePlus made by the one and only ForeverHD. What you would be doing is creating a folder for your zone, putting specific boundings for where you want your coins to spawn in the folder and then using the :getRandomPoint() function to get a random vector in your zone.
I did that at his request though?
Yeah, that’s happening because there are only 2 possible spawn locations and you set the coins to spawn every second. Other than that the script works.
OP wanted it to spawn between the two positions, not at one or the other at random.
Well scattered around the 2 positions, like for example, how Pet Simulator X does it, or just any other game
local spawncframes = {CFrame.new(699.21, 30.062, -5415.25), CFrame.new(684.67, 30.062, -5435.845)}
local rand = math.random(1, #spawncframes)
local coin = game.ServerStorage:WaitForChild("Coin")
while task.wait(1) do
local coinclone = coin:Clone()
local randoms = math.random(-5, 5)
coinclone.CFrame = spawncframes[rand] + CFrame.new(randoms, randoms, randoms)
coinclone.Parent = workspace
end
Here, the coins will now scatter around those two spawn areas. I didn’t realise this was the behavior you wanted.
I’ve created an example for you, I dislike spoon feeding as it completely removes any point of me replying but whatever.
I’ll link you the API as well so you can do your own reading up.
Zone - ZonePlus (1foreverhd.github.io)
Here’s a basic coin spawning system. It won’t reward anything but it just instances new parts on a random position in a zone.
CoinSpawner.rbxl (65.5 KB)
Have a nice day/night.
I seem to get this error? (I think I fixed it) Also how can I make it have a max Coins in that spot? Lets say 5 coins max in that area
It’s still going to spawn in a very limited position and in a real game will indeed look off.
local spawncframes = {CFrame.new(699.21, 30.062, -5415.25), CFrame.new(684.67, 30.062, -5435.845)}
local rand = math.random(1, #spawncframes)
local coin = game.ServerStorage:WaitForChild("Coin")
while task.wait(10) do
local coinclone = coin:Clone()
local random = math.random(-5, 5)
coinclone.CFrame = spawncframes[rand]
coinclone.Position += Vector3.new(random, random, random)
coinclone.Parent = workspace
end
How can I make it spawn a Coin with scripts inside it, if you don’t mind answering.
You would used .Touched (make sure to destroy the connection afterwards of course) to detect when the coin has been touched. From there you would program it to add a number to a leaderstat and so on. There are tutorials for this on youtube by the way.
No no I mean for it to spawn a Coin that I already have, instead of the brick…
You would parent the coin to the spawner script, use a variable to define it and then instead of instancing a part just clone the coin.
It would look fine if you want specific areas which spawn coins as opposed to an entire map with randomly spawned coins.