Executing various Functions and joining the variables into one

As the title says, I wanted to run multiple functions at the same time, which are going to give me variable-results and then I want to use all that variables to execute in one function.

Imagine, I want to list all of the players online, make the distance between them and an object, choose the minimal, and then from thst get the players name, and execute this always, every second, always getting the nearest player name. But I cant do it on the same scipt, because the process gets really slow ( I think its because the server has to do the same process for every player online, and then the other thing I want to do is to move that part 1 stud forward in the player choosen direction)

So basically, I want to always execute a process and get an always cehckimg output, and share that variable with another scipt.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

roblox lua should run everything in seperate threads so no matter tha ammount, the speed should not decrease very drastically but instead the process will be more expensive and cause “lag”

However,

since you are communicating between multiple scripts…
you could use bindable events and one script can fire it
and all the others will recieve .Event… and fire the data back through another bindable event

then the original script that fired will wait for all the data to come back through

sendbindable:Fire(data
local recieveCount = 0;
local connection = recievebindable.Event:Connect(function(databack)
    recieveCount += 1
    -- use databack here ig add them together to a variable outside- whatever
    if (recieveCount >= howManyRecievers) then
        connection:Disconnect()
    end)
end)
task.wait(1) - took too long
connection:Disconnect() -- took too long disconnect

I highly dont recomend this method as it is very inefficient.
Your problem can be done using just 1 script.

Can you elaborate some more on your use case? I don’t believe your approach is the right way to handle your issue.