Hey, does anyone know how to change all the players in the same server to 1 random player? please let me know bc i need this for my live event,
thx for reading!
I haven’t tested it but here is a script I made just now
local function randomPlayer()
local unselectedPlayers = game.Players:GetPlayers()
local unchangedPlayers = game.Players:GetPlayers()
local totalPlayers = game.Players:GetPlayers()
local matches = {}
for i = 1, #unchangedPlayers, 1 do
local random = math.random(1, #unselectedPlayers)
matches[unchangedPlayers[i]] = unselectedPlayers[random].Character
table.remove(unchangedPlayers, unchangedPlayers[i])
table.remove(unselectedPlayers, unselectedPlayers[random])
end
for player, appearance in pairs(matches) do
player.Character = appearance
end
end
Let me test, already thx for the help
is it local? or server, please let me know if possible
server
aisdgasgiudgasidsadasdsagasgsa
i didnt work
srry, i debuged and it said only the things outside of the function, no errors
did you call the function?
somewhere below it, type randomPlayer()
local function randomPlayer()
local unselectedPlayers = game.Players:GetPlayers()
local unchangedPlayers = game.Players:GetPlayers()
local totalPlayers = game.Players:GetPlayers()
local matches = {}
for i = 1, #unchangedPlayers, 1 do
local random = math.random(1, #unselectedPlayers)
matches[unchangedPlayers[i]] = unselectedPlayers[random].Character
table.remove(unchangedPlayers, table.find(unchangedPlayers[i]))
table.remove(unselectedPlayers, table.find(unselectedPlayers[random]))
end
for player, appearance in pairs(matches) do
player.Character = appearance
end
end
Try this
i mean i debugged and that was working (the print in the middle of the script) but i dint error and didnt change the character
can you put the following before the for player, appearance in pairs(matches) do
for key, value in pairs(matches) do
print(key .. " is " .. value)
end
and then tell me what it outputs?
I won’t send you whole script only some parts but here u go:
local plrTable = game.Players:GetPlayers()
local player = plrTable[math.random(1, #plrTable]
table.remove(plrTable, table.find(plrTable, player))
for i,v in pairs(plrTable) do
--change avatar to player
for _,part in pairs(v.Character:GetChildren()) do -- Remove all Accessories/Pants,Shirts,T-Shirts in plr
if not v:IsA("BasePart") and not v:IsA("Humanoid") then
v:Destroy()
end
end
v.Character.Humanoid -- apply description...
end
https://developer.roblox.com/en-us/articles/humanoiddescription-system
should be
table.remove(unchangedPlayers, table.find(unchangedPlayers, unchangedPlayers[i]))
table.remove(unselectedPlayers, table.find(unselectedPlayers, unselectedPlayers[random]))

