How to choose a model at random to spawn?
Hi there!
I have a script that is supposed to choose a random number using math.random, and then when a specific number is chosen, there is an if statement of what to do about that number. (it tells a model to spawn based on what number was chosen).
Right now, there's no error, it's just choosing the last "if" statement every time (it just keeps spawning ring4) instead of adequately choosing a number or following what to do after the number is chosen, not sure which... the weirdest thing is that if I spam the button, then it gives me a number other than 4. BUT if I spawn in and press the button, like clockwork every time it chooses 4. It needs to be random, even on the first click..
03 | local randomRing = math.random( 1 , 4 ) |
07 | if randomRing = = 1 then |
09 | game.ReplicatedStorage.rings.rings 1 :FireServer() |
11 | else if randomRing = = 2 then |
13 | game.ReplicatedStorage.rings.rings 2 :FireServer() |
15 | else if randomRing = = 3 then |
17 | game.ReplicatedStorage.rings.rings 3 :FireServer() |
19 | else if randomRing = = 4 then |
21 | game.ReplicatedStorage.rings.rings 4 :FireServer() |
27 | script.Parent.MouseButton 1 Down:connect(onClicked) |
Thanks for your help!