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.
lastkey = nil function SpawnKeys() keys = game.Workspace.Map.Main.GameKey:GetChildren() pickedkeys = math.random(1, #keys) if keys[pickedkeys].Name == lastkey then SpawnKeys() else lastkey = keys[pickedkeys].Name for i = 1, #keys do local keyspawns = game.Workspace.Map.Main.keyspawn.KeyParts keys[i].Position = keyspawns.Position keyspawns:Remove() end end end
I want the keys to spawn into different locations of the map, but for some reason it stays in the same location every time.