Does Spawn(function()) stilll throttle the code?

We have established that task.spawn is better than spawn, so there is no need to argue as you both agree.

1 Like

Yup, the task library works exactly like the original ones except it doesn’t throttle as much.

task.wait(n)
task.spawn(function)
task.delay(secondstowait, function) --basically task.wait in a task.spawn at the start
--the other ones here

I’m not arguing, I’m asking. Idc if its better or not. I care about if in 5 years from now it will be gone.

so what amm i supposed to use now?!?!?

Use task.spawn instead of spawn.

so just like this?


function BounceEffect(Model)
	spawn(function()
		--Clone the model, so that we can add the effect on the clone
		local BounceModel = Model:Clone()
		BounceModel.Parent = Model.Parent

		--Loop through the children of the model to change their color and tween them
		for a,b in ipairs(BounceModel:GetDescendants())do 
			if not b:IsA("BasePart") then b:Destroy() end
			--Change the color and material to the desired effect
			b.Material = Enum.Material.Plastic
			b.Color = Color3.new(1, 1, 1)
			--For the effect to not interfere with the player, make it uncollidable
			b.CanCollide = false
			b.CanTouch = false
			b.Anchored = true

			game.TweenService:Create(b,TweenInfo.new(0.5,Enum.EasingStyle.Bounce),{Transparency = 1,Size = b.Size * 1.5}):Play()
		end

		--wait for everything to finish and clean up the model
		task.wait(0.5)
		BounceModel:Destroy()
	end)
end

script.RECIEVER.Event:Connect(BounceEffect)
1 Like

Add task. before your spawn. That’s it.

so i can do many at same time without script throttled?

Just replace that with task.spawn(function()
Absolutely no changes needed.

2 Likes

Thank you for this very relevant reply to this discussion.

your welcome. his name is bob…

1 Like

Alright, enough derailing since this topic may get taken down, please just mark it as solved with whatever reply here

You should probably set a solution to the post.

1 Like

okay. bob is the only right answer. thank you all

1 Like

Well, there is a small, and pretty big misconception here, which is pretty common amongst everybody I have seen, or paid attention to.

spawn() and task.spawn() are not the same thing, nor are they related, nor do does one supercede the other, they never have. For an actual replacement of spawn(), you will find task.defer(), which is functionally the same as spawn()

Officials from Roblox also state this themselves

so better use defer? or is it same as spawn?

Its basically like spawn(), but without throttling, which is what you were asking for.

alright thaknsalright thaknsalright thakns

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.