Advertisement
KrYn0MoRe

gif script

Jun 9th, 2020 (edited)
2,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. local spart = Instance.new("Part")
  2. spart.Parent = script
  3. spart.CFrame = CFrame.new(1.15006196, 7.37997007, -0.665921986, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  4. spart.Orientation = Vector3.new(0, 180, 0)
  5. spart.Color = Color3.new(0.972549, 0.972549, 0.972549)
  6. spart.Size = Vector3.new(26.2399158, 14.7599401, 0.151851237)
  7. spart.Material = Enum.Material.SmoothPlastic
  8. spart.Anchored = true
  9. spart.Locked = false
  10. spart.CanCollide = true
  11.  
  12. local plr = owner
  13.  
  14. -- https://jacklehamster.github.io/utils/gif2sprite/
  15.  
  16. local gifs = {
  17.     ['sonic'] = {
  18.         image_id = 5159161618,
  19.         rows = 13,
  20.         columns = 7,
  21.         fps = 10,
  22.         frames = 89,
  23.         full60fps = false,
  24.     },
  25.     ['rickroll'] = {
  26.         image_id = 5159003271,
  27.         rows = 7,
  28.         columns = 5,
  29.         fps = 15,
  30.         frames = 31,
  31.         full60fps = false,
  32.     },
  33.     ['social'] = {
  34.         image_id = 5159174648,
  35.         rows = 5,
  36.         columns = 5,
  37.         fps = 30,
  38.         frames = 25,
  39.         full60fps = false,
  40.     },
  41. }
  42.  
  43. local image = Instance.new("Texture")
  44. image.Face = "Front"
  45. image.Parent = spart
  46.  
  47. local currentFrame = 1
  48. local currentRow,CurrentColumn = 0,0
  49. local linear = false
  50. local rows,columns = 0,0
  51. local fps = 1
  52. local frames = 0
  53. local full60fps = true
  54. local size = spart.Size
  55.  
  56. function setup_gif(id)
  57.     local gif = gifs[id]
  58.     if gif then else return end
  59.     rows = gif.rows
  60.     columns = gif.columns
  61.     currentRow,CurrentColumn,currentFrame = 1,1,1
  62.     full60fps = gif.full60fps
  63.     fps = gif.fps
  64.     frames = gif.frames
  65.     image.Texture = 'rbxassetid://' .. gif.image_id
  66.     image.StudsPerTileU = columns*size.X
  67.     image.StudsPerTileV = rows*size.Y
  68. end
  69.  
  70. setup_gif('rickroll')
  71.  
  72. plr.Chatted:Connect(function(msg)
  73.     if msg:lower():sub(1,4) == 'gif/' then
  74.         local id = msg:lower():sub(5)
  75.         setup_gif(id)
  76.     elseif msg:lower():sub(1,7) == '/e gif/' then
  77.         local id = msg:lower():sub(8)
  78.         setup_gif(id)
  79.     end
  80. end)
  81.  
  82. while true do
  83.     if not full60fps then wait(1/fps) else game:GetService("RunService").Stepped:Wait() end
  84.     if linear then
  85.         image.OffsetStudsU = image.OffsetStudsU + size.X
  86.         if image.OffsetStudsU > image.StudsPerTileU then
  87.             image.OffsetStudsU = 0
  88.         end
  89.     else
  90.         CurrentColumn = CurrentColumn + 1
  91.         if CurrentColumn > columns then
  92.             CurrentColumn = 1
  93.             currentRow = currentRow + 1
  94.         end
  95.         if currentFrame > frames then
  96.             currentRow,CurrentColumn,currentFrame = 1,1,1
  97.         end
  98.         image.OffsetStudsU = size.X*(CurrentColumn-1)
  99.         image.OffsetStudsV = size.Y*(currentRow-1)
  100.         currentFrame = currentFrame+1
  101.     end
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement