Roblox Built In Loop Functions VS Custom Loops

I was wondering this for a quite second; and I wanted to know if it’s better for performance and just overall gameplay if I were to use built in loop function roblox provides or my own

For example,

Custom Loop

local connection
connection = game:GetService("RunService").Heartbeat:Connect(function()
	Part.CFrame = anotherPart.CFrame
end)
mouse.Move:Connect(function()
	Part.CFrame = anotherPart.CFrame
end)

I would honestly suggest you use the built in roblox method if it exists since that method has built in support for what you are trying to do, and the “custom loop alternative” wouldn’t necessarily be optimized for what you are trying to achieve, even though there are some exceptions where using a loop might be better if it is a widely accepted lua / roblox built in I dont see a reason to not take advantage of it.

Also to add to what you were saying connections arent really loops they observe changes and than execute a callback when a change is observed, im not sure how roblox signals work behind the scenes but just wanted to distinguished the two.

Oh alright dude this really makes sense and answered my question thoroughly thanks alot

1 Like