This problem does not require a loop. Since there's only one player you want to affect, there's no need to go over the whole thing (probably).
To select something randomly from a list (the list we will be using is GetPlayers) we have to generate a random index from the list (1, 2, 3, 4, ... , length of list - 1, length of list). We do that with this simple line:
local randomIndex = math.random(1 , #list);
Then, to get the random object from the list, we just have to ask for the object at that index:
local randomObject = list[randomIndex];
For getting a random player, it would look like this:
local allPlayers = game:GetService("Players"):GetPlayers();
if #allPlayers >= 1 then
local randomPlayerIndex = math.random(1,#allPlayers);
local randomPlayer = allPlayers[randomPlayerIndex];
if randomPlayer.Character then
randomPlayer.Character:BreakJoints();
end
end
2 comments
Why is this tagged trigonometry, functons and localscripts? They are all irrelevant.
@Duel there tags, Ik I didnt put tan() cos() and sin()