How to put items in random?

Hey devs I need some help.
I’m making a piggy inspired game and I’m using @Alvin_Blox’s piggy kit to make my game.
I want my game to put the items to spawn at different spots in the map.

Through this time I made a stupid script.
I made a script that changes the postion of the items by using Vector3
and making it change it’s position until a part in workspace called MovePart
has been touched.

After a little time I realized that it would only work for one time.

Can anyone tell me how I can make it possible?

Could i see the item spawning code? I might try solving it out.

If it works one time, then use a while loop to repeat it every amount of time you want. Like

while true do
     wait(60)
     --move item function
end

The items are already placed in the map.

You can either use the Random datatype or math.random to generate psuedorandom numbers.

Then you might have to spawn them by a script if you want the items not be for 1 time but multiple

group all the MoveParts then

local groupName = game.Workspace.GroupName

local block = groupName[math.random(1,#groupName)]

key.Position = block.Position

This one solved my problem and it was the easiest.
Thanks for helping :happy2:

@Andr_yy and @EHGTR1903 thanks for trying to help me too.
Much appreciated.

1 Like