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

[EDIT] Why is my animated decal flickering even when I preload image?

Asked by 6 years ago
Edited 6 years ago

-- Scripted by Qwerty1806, decals uploaded by Skattzers. -- 2014:07:14 <-- This is how you're supposed to write dates according to international standards. FPS = 30 -- How many frames per second it will run at. Maximum is 30 due to engine restrictions. GIF = {"rbxassetid://1079751241", --1 "rbxassetid://1079754831", --2 "rbxassetid://1079886634", --3 "rbxassetid://1079935380", --4 "rbxassetid://1079977768", --5 "rbxassetid://1081536230", --6 "rbxassetid://1081542222", --7 "rbxassetid://1081547184", --8 "rbxassetid://1081566081", --9 "rbxassetid://1081575493", --10 "rbxassetid://1081597431", --11 "rbxassetid://1081606706", --12 "rbxassetid://1081612535", --13 "rbxassetid://1081620445", --14 "rbxassetid://1081626873", --15 "rbxassetid://1081647971", --16 "rbxassetid://1081676772", --17 "rbxassetid://1081693386", --18 "rbxassetid://1081698527", --19 "rbxassetid://1081827995", --20 "rbxassetid://1081861970", --21 "rbxassetid://1081878169", --22 "rbxassetid://1081901607", --23 "rbxassetid://1081903484", --24 "rbxassetid://1081913246", --25 "rbxassetid://1081916173", --26 "rbxassetid://1081920401", --27 "rbxassetid://1081938155", --28 "rbxassetid://1081956746", --29 "rbxassetid://1082011739", --30 "rbxassetid://1082018267", --31 "rbxassetid://1082094152", --32 "rbxassetid://1082096049", --33 "rbxassetid://1082118278", --34 "rbxassetid://1082119428", --35 "rbxassetid://1082177730", --36 "rbxassetid://1082178815", --37 "rbxassetid://1082224876", --38 "rbxassetid://1082226714", --39 "rbxassetid://1082229258", --40 "rbxassetid://1082263033", --41 "rbxassetid://1082272800", --42 "rbxassetid://1082273481", --43 "rbxassetid://1082275409", --44 "rbxassetid://1082276886", --45 "rbxassetid://1082277883", --46 "rbxassetid://1082288338", --47 "rbxassetid://1082292793", --48 "rbxassetid://1082292793", --49 "rbxassetid://1082295423", --50 "rbxassetid://1082294467", --51 "rbxassetid://1082297789", --52 "rbxassetid://1082298736", --53 "rbxassetid://1082322120", --54 "rbxassetid://1082323611", --55 "rbxassetid://1082326087", --56 "rbxassetid://1082328313", --57 "rbxassetid://1082330756", --58 "rbxassetid://1082331493", --59 "rbxassetid://1082331923", --60 "rbxassetid://1082333195", --61 "rbxassetid://1082333700", --62 "rbxassetid://1082334172", --63 "rbxassetid://1082334808", --64 "rbxassetid://1082336619", --65 "rbxassetid://1082340492", --66 "rbxassetid://1082341475", --67 "rbxassetid://1082342257", --68 "rbxassetid://1082343496", --69 "rbxassetid://1082344133", --70 "rbxassetid://1082345217", --71 "rbxassetid://1082345852", --72 "rbxassetid://108234709", --73 "rbxassetid://1082350423", --74 "rbxassetid://1082351567", --75 } Image = script.Parent:WaitForChild("Decal") -- Did you know GIF is supposed to be pronounced JIF? for N,F in ipairs(GIF) do game:GetService("ContentProvider"):PreloadAsync(F) -- This preloads each decal, so you don't have to deal with flashing decals. Instance.new("Decal", script.Parent) end while true do for N,F in ipairs(GIF) do -- Run through the GIF table. Image.Texture = F wait(1/FPS) end end } local Image = script.Parent -- Did you know GIF is supposed to be pronounced JIF? for N,F in ipairs(GIF) do game:GetService("ContentProvider"):Preload(F) -- This preloads each decal, so you don't have to deal with flashing decals. end while true do for N,F in ipairs(GIF) do -- Run through the GIF table. Image.Image = F wait(1/FPS) end end
1
http://wiki.roblox.com/index.php?title=API:Class/ContentProvider/PreloadAsync takes in an array of instances (this is a somewhat-recent change). You will have to convert that into an array of decals, and then pass those to PreloadAsync. XAXA 1569 — 6y

1 answer

Log in to vote
2
Answered by
XAXA 1569 Moderation Voter
6 years ago
Edited 6 years ago

PreloadAsync takes an array of instances. This was a change made relatively recently. To work around this, you have to create a decal for each ID in the list, and then preload each of those decals.

local FPS = 60 -- How many frames per second it will run at. Maximum is 30 due to engine restrictions.
local GIF = {"rbxassetid://1079751241", --1
       "rbxassetid://1079754831", --2
       "rbxassetid://1079886634", --3
       "rbxassetid://1079935380", --4 
       "rbxassetid://1079977768", --5
       "rbxassetid://1081536230", --6
       "rbxassetid://1081542222", --7
       "rbxassetid://1081547184", --8
       "rbxassetid://1081566081", --9
       "rbxassetid://1081575493", --10
       "rbxassetid://1081597431", --11
       "rbxassetid://1081606706", --12
       "rbxassetid://1081612535", --13
       "rbxassetid://1081620445", --14
       "rbxassetid://1081626873", --15
       "rbxassetid://1081647971", --16
       "rbxassetid://1081676772", --17
       "rbxassetid://1081693386", --18
       "rbxassetid://1081698527", --19
       "rbxassetid://1081827995", --20
       "rbxassetid://1081861970", --21
       "rbxassetid://1081878169", --22
       "rbxassetid://1081901607", --23
       "rbxassetid://1081903484", --24
       "rbxassetid://1081913246", --25
       "rbxassetid://1081916173", --26
       "rbxassetid://1081920401", --27
       "rbxassetid://1081938155", --28
       "rbxassetid://1081956746", --29
       "rbxassetid://1082011739", --30
       "rbxassetid://1082018267", --31
       "rbxassetid://1082094152", --32
       "rbxassetid://1082096049", --33
       "rbxassetid://1082118278", --34
       "rbxassetid://1082119428", --35
       "rbxassetid://1082177730", --36
       "rbxassetid://1082178815", --37
       "rbxassetid://1082224876", --38
       "rbxassetid://1082226714", --39
       "rbxassetid://1082229258", --40
       "rbxassetid://1082263033", --41
       "rbxassetid://1082272800", --42
       "rbxassetid://1082273481", --43
       "rbxassetid://1082275409", --44
       "rbxassetid://1082276886", --45
       "rbxassetid://1082277883", --46
       "rbxassetid://1082288338", --47  
       "rbxassetid://1082292793", --48
       "rbxassetid://1082292793", --49
       "rbxassetid://1082295423", --50
       "rbxassetid://1082294467", --51
       "rbxassetid://1082297789", --52  
       "rbxassetid://1082298736", --53
       "rbxassetid://1082322120", --54
       "rbxassetid://1082323611", --55
       "rbxassetid://1082326087", --56  
       "rbxassetid://1082328313", --57
       "rbxassetid://1082330756", --58
       "rbxassetid://1082331493", --59
       "rbxassetid://1082331923", --60
       "rbxassetid://1082333195", --61
       "rbxassetid://1082333700", --62
       "rbxassetid://1082334172", --63
       "rbxassetid://1082334808", --64 
       "rbxassetid://1082336619", --65
       "rbxassetid://1082340492", --66
       "rbxassetid://1082341475", --67
       "rbxassetid://1082342257", --68
       "rbxassetid://1082343496", --69
       "rbxassetid://1082344133", --70
       "rbxassetid://1082345217", --71
       "rbxassetid://1082345852", --72
       "rbxassetid://108234709",  --73
       "rbxassetid://1082350423", --74
       "rbxassetid://1082351567", --75
} 


local Image = script.Parent:WaitForChild("Decal")
local ContentProvider = Game:GetService("ContentProvider")

local function LoadImages(imageList)
    local decalList = {}
    for _, textureId in pairs(imageList)
        local decal = Instance.new("Decal")
        decal.Texture = textureId
        table.insert(decalList, decal)
    end

    ContentProvider:PreloadAsync(decalList)
end

LoadImages(GIF)

while true do
    for _, textureId  in pairs(GIF) do
        Image.Texture = textureId  
        wait(1/FPS)
    end
end



2
Remember that Game is deprecated, so use game! hiimgoodpack 2009 — 6y
0
@XAXA Do I have to insert the array into the decal list as well? JoeRaptor 72 — 6y
0
I'm not sure how to fix that flickering problem. Does the flickering occur even after the gif has looped once? XAXA 1569 — 6y
0
@XAXA Yes, it does. It's an ongoing frame. It happens every time the decal updates. JoeRaptor 72 — 6y
View all comments (7 more)
0
I'm afraid I can't provide a solution without going into too much detail. But an idea would be that you can alternate two frames of the gif with two decals so that it won't appear to flicker (assuming that the entire gif is opaque). XAXA 1569 — 6y
0
You can also try using a SurfaceGui and see if that fixes your problem. XAXA 1569 — 6y
0
I'll try but this happens with screen guis and decals. JoeRaptor 72 — 6y
0
@XAXA Please do continue to go into detail due to the fact I seriously cannot find any other help else because no one is willing to speak or really knows how to do this. JoeRaptor 72 — 6y
0
Why are you looping through the imageList argument and placing them into a new table then preloading the new table? Seems inefficient. hiimgoodpack 2009 — 6y
0
Because ContentProvider:PreloadAsync requires a table of instances. Remember that PreloadAsync blocks until loading is done. Because of that, loading each individual decal takes longer than loading a batch of decals. XAXA 1569 — 6y
0
@XAXA Again, about going into further detail, I am all ears. It's been 18 days since I first posted this thing. And have gotten no other help, than you so far. JoeRaptor 72 — 6y
Ad

Answer this question