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

How do I improve the performance of my .gif GUI with 70 images (1 frame per 0.04 second)?

Asked by
Seraine 103
8 years ago

This is a section of the script, altogether there's 70 images. At the moment the images keeps on flashing because of latency, it also freezes and then plays perfectly for a split second and then flashes again. Is there anyway I can make it so the images change without flashing?

1while true do
2    wait(0.04)
3    script.Parent.Image = "rbxassetid://544664857"--0
4    wait(0.04)
5    script.Parent.Image = "rbxassetid://544665861"--1
6    wait(0.04)
7    script.Parent.Image = "rbxassetid://544666597"--2
8end

Here's the place with the .gif GUI: https://www.roblox.com/games/544685431/Seraines-Place-Number-40

Thanks

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago
Edited 8 years ago

wait() isn't very precise, especially with very short times. You need to use a delta time loop to handle this.

Additionally, the only way to combat the latency is to script this using a LocalScript.

01local frames = {
02    {img = 544664857, rate = .04};
03    {img = 544665861, rate = .04};
04    {img = 544666597, rate = .04};
05}
06 
07--EDIT - yep, I forgot to have the images preloaded! Let's fix that here:
08do
09    local ContentProvider = game:GetService("ContentProvider")
10    local images = {}
11    for _, v in ipairs(frames) do
12        table.insert(images, "rbxassetid://" .. v.img)
13    end
14    ContentProvider:PreloadAsync(images)
15end
View all 37 lines...

Delta time usage is a confusing concept to understand, so definitely ask any questions you have about it!

Some references that may be helpful:

1
You forgot to account for the fact that the frames aren't preloaded. User#6546 35 — 8y
0
Yeah the gif doesn't play ;c Seraine 103 — 8y
0
Thanks for you help, but the loop stops after every frame has been played, you can see it here: https://www.roblox.com/games/544685431/Seraines-Place-Number-40 Seraine 103 — 8y
Ad

Answer this question