Sprite sheets on GUI?

Hey, I have just discovered this script by @HungryFox02 but it would only work for Surface GUIs, how do I modify so that I can use it for screen GUIs too? (Image labels)

-- Script by HungryBoy02

local Frames = 6*2 --Amount of frames in gif
local currentFrame = 1

local rows = 4
local columns = 3

local currentRow,CurrentColumn = 0,0

local linear = false

local fps = 10 -- Max 30
local full60fps = false

local size = script.Parent.Parent.Size -- The gif should be on the front of the part

script.Parent.StudsPerTileU = columns*size.X
script.Parent.StudsPerTileV = rows*size.Y

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

You probably don’t, it’d need to be completely rewrote. Which is not even worth it in the long run, so best case would be to just write a screengui specific script

what do u mean? so how can I use sprite sheets to make a gif on the screen gui then

You would have to change the code drastically due to the differences between the GUI types.

Actually that was written for a texture, not a GUI at all, as scripting for surface guis and screen GUIs are practically identical.

Oh, he never mentioned anything about a texture and I only skimmed the code, but my point still stands that the code would be changed a lot to fit a different type of instance.

Is there a way to make it work for a image label?

Yes, ive done this in my game, i would help but currently i am unable to use my computer

1 Like