0

I have a coin which rotates and changes size so far. I want to be able to set an area (which is not a nice square of course) that they can randomly spawn locations. The thing it has to do is once there are less that 7 coins then it spawns more.

Anyone able to give me some advice? Not sure what is most efficient method.

  • Heyo, do you have any code to share from your attempt to solve it? What piece of this are you having trouble with? Spawning the objects? Choosing random locations within a square? And did you run into any errors when you attempted it? – Kylaaa Sep 21 '22 at 14:40
  • I haven't got any code for it because i really don't know how to go about it. I did do some research and it varies to local scripts, magnitude, cframe, raycasting... so i am trying to get an opinion about what is actually recommended. – Dr_ArmyDevRBX Sep 21 '22 at 15:25
  • 1
    I personally recommend setting spawn locations manually, if possible. Looks better, and is usually less buggy. – Luke100000 Sep 21 '22 at 15:28
  • @Luke100000 Can you still randomise it ? – Dr_ArmyDevRBX Sep 21 '22 at 15:38
  • If you're looking for a place to start, [this question](https://stackoverflow.com/questions/73178823/how-to-optimize-an-overuse-of-if-statements-in-roblox-studio/73186850) was rather similar. It's not exactly what you're asking, but it might be a helpful place to start – Kylaaa Sep 21 '22 at 16:29
  • Really stupid question here: How do i put the position in a table? I am trying bits of code off the optimization thread you suggested/the manual spawn locations – Dr_ArmyDevRBX Sep 21 '22 at 19:29

2 Answers2

1

It sounds like you should be making use of ZonePlus and its getRandomPoint function.

If you want a direct reference, the creator of the module made a playground and its source code is publicly viewable. The playground contains a 'CoinSpawner' (literally what you're looking for).

AllowSleep
  • 21
  • 6
  • 1
    I will give that a go in the morning. Sounds exactly what I need. Just checked their game demo and it seems overpowered. Haha, thanks so much!! – Dr_ArmyDevRBX Sep 21 '22 at 19:53
0

You can either make use of "Region3" or you can set up multiple possible spawn points and run a math.random function to choose which one.

Bent
  • 1