Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- booms framiez
- local Frames = 26 -- amount of frames in gif
- local currentFrame = 1
- local rows = 5 -- how many rows (horizontal) does it have
- local columns = 6 -- how many colums (vertical) does it have
- local linear = false -- use linear?
- local fps = 12 -- higher = smoother / lower = less smoother, max is 30
- local full60fps = false -- 60 frames?
- local spritesheettexture = "rbxassetid://3528512681"
- -- DONT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING!
- function createModel()
- local partsWithId = {}
- local awaitRef = {}
- local root = {
- ID = 0;
- Type = "Part";
- Properties = {
- BottomSurface = Enum.SurfaceType.Smooth;
- Anchored = true;
- Rotation = Vector3.new(-180,0,-180);
- Name = "Spritegif";
- Position = Vector3.new(9.9999980926514,5.000030040741,0);
- Orientation = Vector3.new(0,180,0);
- Size = Vector3.new(10,10,0.050000000745058);
- CFrame = CFrame.new(9.9999980926514,5.000030040741,0,-1,0,0,0,1,0,0,0,-1);
- TopSurface = Enum.SurfaceType.Smooth;
- };
- Children = {
- {
- ID = 1;
- Type = "Texture";
- Properties = {
- Texture = spritesheettexture;
- StudsPerTileV = 50;
- Name = "Gif";
- StudsPerTileU = 40;
- };
- Children = {
- {
- ID = 2;
- Type = "Script";
- Properties = {
- Name = "GifScript";
- };
- Children = {};
- };
- };
- };
- };
- };
- local function Scan(item, parent)
- local obj = Instance.new(item.Type)
- if (item.ID) then
- local awaiting = awaitRef[item.ID]
- if (awaiting) then
- awaiting[1][awaiting[2]] = obj
- awaitRef[item.ID] = nil
- else
- partsWithId[item.ID] = obj
- end
- end
- for p,v in pairs(item.Properties) do
- if (type(v) == "string") then
- local id = tonumber(v:match("^_R:(%w+)_$"))
- if (id) then
- if (partsWithId[id]) then
- v = partsWithId[id]
- else
- awaitRef[id] = {obj, p}
- v = nil
- end
- end
- end
- obj[p] = v
- end
- for _,c in pairs(item.Children) do
- Scan(c, obj)
- end
- obj.Parent = parent
- return obj
- end
- return function() return Scan(root, nil) end
- end
- warn("finished loading in gif")
- local model = createModel()()
- model.Parent = workspace
- wait(0.3)
- local currentRow,CurrentColumn = 0,0
- local size = model.Size -- The gif should be on the front of the part
- model.Gif.StudsPerTileU = columns*size.X
- model.Gif.StudsPerTileV = rows*size.Y
- while true do
- if not full60fps then wait(1/fps) else game:GetService("RunService").Stepped:Wait() end
- if linear then
- model.Gif.OffsetStudsU = model.Gif.OffsetStudsU + size.X
- if model.Gif.OffsetStudsU > model.Gif.StudsPerTileU then
- model.Gif.OffsetStudsU = 0
- end
- else
- CurrentColumn = CurrentColumn + 1
- if CurrentColumn > columns then
- CurrentColumn = 1
- currentRow = currentRow + 1
- end
- if currentFrame > Frames then
- currentRow,CurrentColumn,currentFrame = 1,1,1
- end
- model.Gif.OffsetStudsU = size.X*(CurrentColumn-1)
- model.Gif.OffsetStudsV = size.Y*(currentRow-1)
- currentFrame = currentFrame+1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement