Making an GIF in ImageLabel (ScreenGui) | Trying to rewrite some random code

So yeah, my goal is to upload an gif to play in an imagelabel. Like an video.
Of course, my poor scripting skills came to play and i tried to “switch” it over from an Decal / texture to an imagelabel (i failed of course)

If you need more explanation feel free to ask :slight_smile:

Here is the code:


local rows = 23
local columns = 5

local Frames = rows*columns
local currentFrame = 1

local currentRow,CurrentColumn = 0,0

local linear = false

local fps = 30
local full60fps = false

local size = script.Parent.Size

local function api()
	local x = columns*size.Y.Scale
	local y = rows*size.X.Scale

	script.Parent.ImageRectOffset.X = x
	script.Parent.ImageRectOffset.Y = y
end

api()

while true do
	if not full60fps then wait(1/fps) else game:GetService("RunService").Stepped:Wait() end
	if linear then
		script.Parent.ImageRectOffset.Y = script.Parent.ImageRectOffset.Y + size.X
		if script.Parent.ImageRectOffset.Y > size then
			script.Parent.ImageRectOffset.Y = 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
		script.Parent.ImageRectOffset.X = size.X*(CurrentColumn-1)
		script.Parent.ImageRectOffset.Y = size.Y*(currentRow-1)
		currentFrame = currentFrame+1
	end
end

Please note that i don’t force you neither do i request from you to fix this script, i only want to know how i can make it be functional

Scripts used in this post are NOT by me, original post: Gifs in Roblox with only 1 image!

I resulted in alot of errors like:

 X cannot be assigned to 
 or
 Y cannot be assigned to

It’s self explanatory. X and Y cannot be assigned to, you have to make a new Vector2 (might be a UDim, and override the entire ImageRectOffset, like so:

script.Parent.ImageRectOffset = Vector2.new(x, y)
1 Like

ah okay, im still learning so you know i ain’t the best :slight_smile:

I did also make a GUI version for image labels

for additional help

oh thanks it means alot to me [hastobe30chars]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.