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?
while true do wait(0.04) script.Parent.Image = "rbxassetid://544664857"--0 wait(0.04) script.Parent.Image = "rbxassetid://544665861"--1 wait(0.04) script.Parent.Image = "rbxassetid://544666597"--2 end
Here's the place with the .gif GUI: https://www.roblox.com/games/544685431/Seraines-Place-Number-40
Thanks
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.
local frames = { {img = 544664857, rate = .04}; {img = 544665861, rate = .04}; {img = 544666597, rate = .04}; } --EDIT - yep, I forgot to have the images preloaded! Let's fix that here: do local ContentProvider = game:GetService("ContentProvider") local images = {} for _, v in ipairs(frames) do table.insert(images, "rbxassetid://" .. v.img) end ContentProvider:PreloadAsync(images) end -- local GUI = script.Parent local RenderStepped = game:GetService("RunService").RenderStepped local i = 1 local extra = 0 while true do GUI.Image = "rbxassetid://" .. frames[i].img local st = tick() + extra while true do RenderStepped:wait() local t = tick() if t - st >= frames[i].rate then extra = t - st - frames[i].rate break end end i = (i + 1)%(#frames + 1) end
Delta time usage is a confusing concept to understand, so definitely ask any questions you have about it!
Some references that may be helpful: