How to make a part spawn in random locations of the map?
This is my attempt:
Basically, I have made 16 different parts for the key to spawn to, but the keys remain in the same spawn, it won't change their position.
04 | keys = game.Workspace.Map.Main.GameKey:GetChildren() |
05 | pickedkeys = math.random( 1 , #keys) |
06 | if keys [ pickedkeys ] .Name = = lastkey then |
09 | lastkey = keys [ pickedkeys ] .Name |
11 | local keyspawns = game.Workspace.Map.Main.keyspawn.KeyParts |
12 | keys [ i ] .Position = keyspawns.Position |
I want the keys to spawn into different locations of the map, but for some reason it stays in the same location every time.