How to randomly teleport players using command blocks? [duplicate]

I want to teleport a player randomly in a 10,000 block radius when they step on a pressure plate. How do I do this?


Solution 1:

Try the /spreadplayers command, which spreads entities in a random area. The syntax is /spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player …>

In your case, you might want to try something like /spreadplayers ~ ~ 0 10000 false @a[r=5,c=1].