Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the "gif" working?

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()

7 comments

0

Change '230054930' to '230054929'. You need to subtract '1' from the id at times to get the 'actual' texture.

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.

0

Thanks!

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.

0

How did I even get a down vote?

0

@ adark , Could I just use Runservice.Heartbeat instead?

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.

2 answers

✓ Accepted answer

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

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>

4 comments

0

I agree with this guy Up Vote!

0

I already know that :\

2

It's actually the rbxassetid:// protocol. rbxasset:// is for stuff saved locally in the ROBLOX installation folders.

0

Thanks for that clarification. @adark

This discussion is preserved as it was. New answers, comments, and votes are closed.