So let’s say I have a module script with the following code:
function module.DoSomething()
while true do
task.wait(1)
end
end
And i want to call that function from another script, how would I call it without it yielding the entire script? task.spawn(module.DoSomething()) didnt work for me
1 Like
function.module:doSomething()
task.spawn(function()
– stuff
end)
end)
1 Like
--Your function
function module.DoSomething()
while true do
task.wait(1)
end
end
--right way to call it in a task
task.spawn(module.DoSomething)
--\\ Example 2 with arguments //--
function module.DoSomething(arg1, arg2, arg3)
print(arg1, arg2, arg3)
while true do
task.wait(1)
end
end
local _arg1 = 1
local _arg2 = 2
local _arg3 = 3
--right way to call it in a task with arguments
task.spawn(module.DoSomething, _arg1, _arg2, _arg3)
2 Likes
–right way to call it in a task with arguments
task.spawn(module.DoSomething, _arg1, _arg2, _arg3)
That’s the thing I’ve been missing, thank you!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.