hey guys, I’ve been using task.spawn() to make a new thread in the background of my currently running code, is there any way to make it look… a bit cleaner?
it looks a lot like unnessary clutter on my code
I remember somebody talking about actors but I’m not too sure if that’s the solution (I also don’t know how to use it lol)
-Avoid using abbreviations like hrp, HumanoidRootPart is way more understandable.
-Localing with _ like body_part is way more uglier then bodyPart or BodyPart for me.
-Use comments which will create more empty space and make you understand it faster in the future.
There’s no need to use actors for this. task.spawn is perfectly fine. If you don’t like the way the block looks in the middle of everything else, put the anonymous function into a named one and call task.spawn with the named function:
local function Animate()
-- code goes here
end
local function EmitParticles()
-- code goes here
end
-- Later on...
task.spawn(Animate)
task.spawn(EmitParticles)
If you need to pass in arguments to the functions, pass them after the function name:
local function foo(a, b, c)
return a + b + c
end
task.spawn(foo, 10, 11, 12)
-- is equivalent to
task.spawn(function()
foo(10, 11, 12)
end)