Making a gif with RunService

Anyone know how I can put a delay on this?

Frames = {251495903,251495914,251495930,251495944,251495974} 

local frame = 1

game:GetService("RunService").Heartbeat:connect(function()
    script.Parent.Image = "http://www.roblox.com/asset/?id="..Frames[frame]
    frame = frame+1
    if frame > #Frames then
        frame = 1
    end
end)

Try to use the deltaTime in RenderStepped. Change the 20 in my script to match your speed.

local Frames = {251495903, 251495914, 251495930, 251495944, 251495974} 

local self = script.Parent

local frame = 0
local frameSize = #Frames

game:GetService("RunService").Heartbeat:connect(function(deltaTime)
    self.Image = "rbxassetid://" .. Frames[math.floor(frame) + 1]
    frame += deltaTime * 20
    
    if frame > frameSize then
        frame = 0
    end
end)
Frames = {251495903,251495914,251495930,251495944,251495974} 

local frame = 1
local run = game:GetService("RunService")

function waitDelay(t)
  for i = 0, t, 1 do
    run.Heartbeat:Wait()
  end
end

while true do
    waitDelay(2)
    script.Parent.Image = "http://www.roblox.com/asset/?id="..Frames[frame]
    frame = frame+1
    if frame > #Frames then
        frame = 1
    end
end

You can skip some frames.

local Frames = {251495903,251495914,251495930,251495944,251495974} 

local frame = 1

local skipCounter = 0

game:GetService("RunService").Heartbeat:Connect(function()
    skipCounter += 1

    if skipCounter % 2 == 0 then
        skipCounter = 0
        if frame > #Frames then
            frame = 1
        end

        frame += 1
    else
        return
    end
end)

Does not work :(, can you help me?

Did you try my script? It works perfectly, just change the * 20 to change the speed.

Make sure you got the most updated version since I edited it a bit.
2IbEcWFQgw

I’m sorry. I didn’t even see your script, btw it worked perfectly, thx.

You should mark things that fix your problem with the solution button! People may stumble upon this and think it is unsolved and or that didn’t work.

I’m sorry I forgot, but I’ve fixed it