Trying to make a for-loop function that runs the code that was given in the parameter of the function call, in a for-loop.
**What solutions have you tried so far?
local Players = game:GetService('Players')
local function ForLoop(Table,Code)
for _, v in Table do
loadstring(Code)()
end
end
ForLoop(Players:GetPlayers(),"print(v.Name)")
But the error says that I am attempting to index nil with Name.
As long as theres a return function(whatever) at the beginning of the loadstring code to make sure the function returned by loadstring() returns another function allowing you to access whatever you need to by calling that function.
Do you know if it’s possible to go further and maybe write a function of some sort so you wouldn’t have to write the (“return function(v) end”) each time?