I'm creating imageLabels in a screenGui, and I want the imageLabels to animate in a certain way depending on the image loaded. 'If the requested image is Image1.png
then set the height, width, number of frames, etc. to numbers according to the dictionary. I'd like to have something like this, but I'm not sure how the localScripts in the imageLabels would access the dictionary without copy pasting it into every script.
The dictionary would resemble this:
dictionary = { image1 = { height = 90, width = 100, frames = 16, image = "rbxgameasset://Images/image_name_1" }, image2 = { height = 70, width = 120, frames = 4, image = "rbxgameasset://Images/image_name_2" }, }
A ModuleScript
is a script that returns a single value. Often, this is a table. Any scripts can then require the module and retrieve that returned value.
-- module script return { image1 = { height = 90, width = 100, frames = 16, image = "rbxgameasset://Images/image_name_1" }, image2 = { height = 70, width = 120, frames = 4, image = "rbxgameasset://Images/image_name_2" }, }
And then any and all scripts can require this.
local dictionary = require(moduleScript) print(dictionary.image1.frames) -- 16