I’ve tried doing rbxassetid:// before all the image ids but that doesnt work, And I looked on the creator hub, and found similar issues but nothing seemed to help!
So I don’t understand why it isnt working, and it gives no errors. So I can’t find the reason it does not work.
seems to work properly.
lemme change a few things >;3
Normal Version:
local imageIds : {number} = {139093553695913,96611340724735,74854335449470};
local assetId : number = imageIds[math.random(1,#imageIds)];
local image:string = "rbxassetid://"..assetId;
-- local script needs to be inside the image label.
script.Parent.Image = image;
Folder Version:
-- == LOADING == --
local ImageFolder : Folder = script.Images;
local imageIds : {string} = {};
for _, v in ImageFolder:GetDescendants() do
if v:IsA("Decal") then
table.insert(imageIds, v.Texture);
end;
end;
-- == ASSIGN THE IMAGE == --
local assetId : string = imageIds[math.random(1,#imageIds)];
-- local script needs to be inside the image label.
script.Parent.Image = assetId;
table.freeze turns a table into read-only mode, meaning they cannot be changed.
local Constants = table.freeze({
IMAGE_SWITCH_TIME = 5,
IMAGE_IDS = {139093553695913,96611340724735,74854335449470}
});
local stop : boolean = false;
local imageIds : {number} = Constants.IMAGE_IDS;
local assetId : number = imageIds[math.random(1,#imageIds)];
task.spawn(function()
task.wait(13) -- TESTING
stop = true;
end);
while task.wait(Constants.IMAGE_SWITCH_TIME) do
if(stop) then
break; -- kill the while loop
end;
assetId = math.random(1,#imageIds);
assetId = imageIds[assetId];
-- you can add sum tweens there if you want...
script.Parent.Image = "rbxassetid://"..assetId;
end
local imageIds : {number} = {139093553695913,96611340724735,74854335449470};
local assetId : number = imageIds[math.random(1,#imageIds)];
local image:string = "rbxassetid://"..assetId;
-- local script needs to be inside the image label.
script.Parent.Image = image;```
Ok this is what it looks like for me (Edit: I think the double quotes might mess it up but it didn’t give any errors with or without, It just showed up as white when I joined the game.)
either change the strings inside the list imageIds to numbers (remove the ")
or change the type {number} to {string}
fixed script:
local imageIds : {string} = {"496782421", "8304400127", "190389549"}; -- hopefully i got these correctly
local assetId : number = imageIds[math.random(1,#imageIds)];
local image:string = "rbxassetid://"..assetId;
-- local script needs to be inside the image label.
script.Parent.Image = image;
You could either make a loading screen, or you could place the image labels or decals of the image into a folder and make them invisible.
Or you could use the second script instead, which automatically grabs the decals from a folder and pushes them into a list.
-- == LOADING == --
local ImageFolder : Folder = script.Images;
local imageIds : {string} = {};
for _, v in ImageFolder:GetDescendants() do
if v:IsA("Decal") then
table.insert(imageIds, v.Texture);
elseif v:IsA("ImageLabel") then
table.insert(imageIds, v.Image);
end;
end;
-- == ASSIGN THE IMAGE == --
local assetId : string = imageIds[math.random(1,#imageIds)];
-- local script needs to be inside the image label.
script.Parent.Image = assetId;
I guess I’ll do the folder thing because I was going to make the image off screen and when you load into a game it will drop down before it loads the player into the game.
Thank you!