Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help Me: Returning Tables & Execution?

How can I return selected players in a table? I'm currently making an admin script.

There's a script that sees if the player exists.

function ReturnPlayers(AdminPlayer, Text)
local Players = {}
if whatever then table.insert(Players, plr.Name)
return Players
end

This script calls for it and checks for it.

if ReturnPlayers(Player, string.sub(Message(7))) then
--do stuff
end

For example, how can I remove a leg of all the players selected? I'd really appreciate if someone could help me or redirect me somewhere.]

I also removed some of the code because it's not the main focus and just took up space in this question.

1 answer

Provided that your ReturnPlayers function executes properly and how you want it to - all you have to do is run a simple for loop.

(once more, this is assuming that ReturnPlayers is returning an array of Player OBJECTS).

local array = ReturnPlayers(args)

for i = 1,#array do
	array[i].Character.RightLeg:Destroy()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.