I was trying to make a house where each part of the building disappears one by one. I was using a wait command in the for loop and realized it was too slow, and I learned that using HeartBeat did it per frame and would be faster.
local house = script.Parent local runservice = game:GetService("RunService") for i,v in pairs(house:GetChildren()) do for i = 1,2 do v.Transparency = v.Transparency + 0.5 wait(runservice.Heartbeat) end end
This is my code that uses the HeartBeat. I made an identical one to this except made wait() blank. After running both of them they both were the same speed. Can someone let me know how to use HeartBeat properly?
This is how the hearbeat loop is used.
game:GetService("RunService").Heartbeat:Connect(function() --script here end)