Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Why isn't the "gif" working?

Asked by 9 years ago

I have a script and it's supposed to be playing a gif. So I have 48 frames and I've only gotten 25 for now. When I test it, the photo starts blinking. At first I thought it was that it wasn't loading. I checked the output and it says something like this:

21:29:17.565 - Image failed to load: http://www.roblox.com/asset/?id=230054930: Failed to resolve texture format

Can anyone help?


Code

frames = {230020795,230021055,230022130,230023083,230023938,230024173,230024269,230024742,230025991,230026076,230028638,230028781,230028829,230028881,230028915,230054690,230054720,230054806,230054865,230054930,230055354,230055573,230055616,230055672,230055788}

function run()
    for i = 1,#frames do
        script.Parent.Image = "http://www.roblox.com/asset/?id="..frames[i]
        wait()
    end
    run()
end

run()
0
Change '230054930' to '230054929'. You need to subtract '1' from the id at times to get the 'actual' texture. DigitalVeer 1473 — 9y
0
Incorrect ID; I just checked ID number '230022130', then -1'd the ID, and the same image came up, the actual ID is '230054929', same with all the other ones. TheeDeathCaster 2368 — 9y
0
Thanks! EzraNehemiah_TF2 3552 — 9y
2
Something I would like to mention is that you should *NEVER EVER* do recursion when you want an infinite loop. Delete lines 3, 8, 9, and 11 and wrap the for loop with a 'while true do' loop. adark 5487 — 9y
View all comments (3 more)
0
How did I even get a down vote? EzraNehemiah_TF2 3552 — 9y
0
@ adark , Could I just use Runservice.Heartbeat instead? EzraNehemiah_TF2 3552 — 9y
0
Yes. Although, at 30FPS, you'll have to grab the time delta to advance the gif sequence sanely. I'll add an answer explaining. adark 5487 — 9y

2 answers

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Your question has already been answered in the comments, but here is an example of how I would program this:

frames = { --[[{ assetId, timeToDisplay}]]
    {230020795, .02}; {230021055, .05} -- and so on
}

local step = game:GetService("RunService").Heartbeat
local st = tick()
local curFrame = 1
while true do
    local t = tick()
    if  t - st >= frames[curFrame][2] then
        st = t
        curFrame = curFrame + 1

        script.Parent.Image = "rbxassetid://" .. frames[curFrame][1]
    end

    step:wait()
end
Ad
Log in to vote
2
Answered by 9 years ago

It seems that your question has already been answered, but as a quick note, rather than typing out that URL, you can also just use rbxassetid://<asset id>

0
I agree with this guy Up Vote! TheDarkOrganism 173 — 9y
0
I already know that :\ EzraNehemiah_TF2 3552 — 9y
2
It's actually the `rbxassetid://` protocol. `rbxasset://` is for stuff saved locally in the ROBLOX installation folders. adark 5487 — 9y
0
Thanks for that clarification. @adark Programmix 285 — 9y

Answer this question