Advertisement
Vzurxy

Untitled

Sep 14th, 2019
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.95 KB | None | 0 0
  1. -- booms framiez
  2.  
  3. local Frames = 41 -- amount of frames in gif
  4. local currentFrame = 1
  5.  
  6. local rows = 9 -- how many rows (horizontal) does it have
  7. local columns = 5 -- how many colums (vertical) does it have
  8.  
  9. local linear = false-- use linear?
  10.  
  11. local fps = 20-- higher = smoother / lower = less smoother, max is 30
  12. local full60fps = false -- 60 frames?
  13. local spritesheettexture = "rbxassetid://3890424930"
  14.  
  15. -- DONT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING!
  16.  
  17. function createModel()
  18. local partsWithId = {}
  19. local awaitRef = {}
  20.  
  21. local root = {
  22.     ID = 0;
  23.     Type = "Part";
  24.     Properties = {
  25.         BottomSurface = Enum.SurfaceType.Smooth;
  26.         Anchored = true;
  27.         Rotation = Vector3.new(-180,0,-180);
  28.         Name = "Spritegif";
  29.         Position = Vector3.new(9.9999980926514,5.000030040741,0);
  30.         Orientation = Vector3.new(0,180,0);
  31.         Size = Vector3.new(75,75,0.5);
  32.         CFrame = CFrame.new(9.9999980926514,5.000030040741,0,-1,0,0,0,1,0,0,0,-1);
  33.         TopSurface = Enum.SurfaceType.Smooth;
  34.     };
  35.     Children = {
  36.         {
  37.             ID = 1;
  38.             Type = "Texture";
  39.             Properties = {
  40.                 Texture = spritesheettexture;
  41.                 StudsPerTileV = 50;
  42.                 Name = "Gif";
  43.                 StudsPerTileU = 40;
  44.             };
  45.             Children = {
  46.                 {
  47.                     ID = 2;
  48.                     Type = "Script";
  49.                     Properties = {
  50.                         Name = "GifScript";
  51.                     };
  52.                     Children = {};
  53.                 };
  54.             };
  55.         };
  56.     };
  57. };
  58. local function Scan(item, parent)
  59.     local obj = Instance.new(item.Type)
  60.     if (item.ID) then
  61.         local awaiting = awaitRef[item.ID]
  62.         if (awaiting) then
  63.             awaiting[1][awaiting[2]] = obj
  64.             awaitRef[item.ID] = nil
  65.         else
  66.             partsWithId[item.ID] = obj
  67.         end
  68.     end
  69.     for p,v in pairs(item.Properties) do
  70.         if (type(v) == "string") then
  71.             local id = tonumber(v:match("^_R:(%w+)_$"))
  72.             if (id) then
  73.                 if (partsWithId[id]) then
  74.                     v = partsWithId[id]
  75.                 else
  76.                     awaitRef[id] = {obj, p}
  77.                     v = nil
  78.                 end
  79.             end
  80.         end
  81.         obj[p] = v
  82.     end
  83.     for _,c in pairs(item.Children) do
  84.         Scan(c, obj)
  85.     end
  86.     obj.Parent = parent
  87.     return obj
  88. end
  89.  
  90. return function() return Scan(root, nil) end
  91. end
  92.  
  93. warn("finished loading in gif")
  94.  
  95. local model = createModel()()
  96. model.Parent = workspace
  97.  
  98. wait(0.3)
  99.  
  100. local currentRow,CurrentColumn = 0,0
  101.  
  102. local size = model.Size -- The gif should be on the front of the part
  103.  
  104. model.Gif.StudsPerTileU = columns*size.X
  105. model.Gif.StudsPerTileV = rows*size.Y
  106.  
  107. while true do
  108.     if not full60fps then wait(1/fps) else game:GetService("RunService").Stepped:Wait() end
  109.     if linear then
  110.         model.Gif.OffsetStudsU = model.Gif.OffsetStudsU + size.X
  111.         if model.Gif.OffsetStudsU > model.Gif.StudsPerTileU then
  112.             model.Gif.OffsetStudsU = 0
  113.         end
  114.     else
  115.         CurrentColumn = CurrentColumn + 1
  116.         if CurrentColumn > columns then
  117.             CurrentColumn = 1
  118.             currentRow = currentRow + 1
  119.         end
  120.         if currentFrame > Frames then
  121.             currentRow,CurrentColumn,currentFrame = 1,1,1
  122.         end
  123.         model.Gif.OffsetStudsU = size.X*(CurrentColumn-1)
  124.         model.Gif.OffsetStudsV = size.Y*(currentRow-1)
  125.         currentFrame = currentFrame+1
  126.     end
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement