I've been thinking about combining several of my scripts together to make them more efficient, but one problem was that I have a while true do statement. However, the rest of the code is comprised of events such as .OnServerEvent:connect(function().
I decided to test this out myself, and these are the two scripts I quickly created:
Server Script:
game.ReplicatedStorage.Event.OnServerEvent:connect(function()
print'hi'
end)
while true do
wait()
print'yo'
end
Client Script:
script.Parent.MouseButton1Down:connect(function()
game.ReplicatedStorage.Event:FireServer()
end)
From what I saw, the while true do statement continually printed "yo", but whenever I clicked the button it printed "hi" without the while true do statement interrupting it. Does this mean that RemoteEvents and RemoteFunctions create a separate thread when used, or is it just due to how the TaskScheduler is set up?
