Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How could I make two image labels display two different images at the same time?

I made a script with the help of Goulstem. The problem is that only one Image for the two image labels displays. It is like it shows the same image twice. Because decals must be 512px by 512, I must divide my 1024px image by two and upload it to roblox. I made two that should appear side to side but it only shows the same image label twice. An error I am getting is

ReplicatedFirst.Loading Screen:7: unfinished string near '"http://www.roblox.com/asset/?id=265748876'

I don't understand the error though.

My Code

--ContentProvider service
local content = game:GetService('ContentProvider')

--Put your images into a table
local images = {
    "http://www.roblox.com/asset/?id=265748963",
    "http://www.roblox.com/asset/?id=265748875"
}

--Load the images, from the table
for _,v in next,images do
    content:Preload(v)
end

--Your Code
script.Parent:RemoveDefaultLoadingScreen()

local screen = Instance.new("ScreenGui")
screen.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

local frame = Instance.new("Frame")
frame.Parent = screen
frame.Size = UDim2.new(1,0,1,0)
frame.BackgroundColor3 = Color3.new(0,0,0)
frame.Transparency = 1

local textlabel = Instance.new("TextLabel")
textlabel.Parent = screen
textlabel.BackgroundColor3 = Color3.new(255,255,255)
textlabel.BackgroundTransparency = 1
textlabel.Transparency = 1
textlabel.Position = UDim2.new(.4,0,0.65,0)
textlabel.Size = UDim2.new(0.25,0,0.1,0)
textlabel.Font = "Legacy"
textlabel.FontSize = "Size24"
textlabel.Text = "Im all fired up!"
textlabel.TextColor3 = Color3.new(0,0,255)
textlabel.TextScaled = true
textlabel.TextWrapped = true
textlabel.TextXAlignment = "Center"
textlabel.TextYAlignment = "Center"

local imagelabel = Instance.new("ImageLabel") 
imagelabel.Parent = frame
imagelabel.BorderSizePixel = 0
imagelabel.Size = UDim2.new(0.5,0,1,0)
imagelabel.ZIndex = 1
imagelabel.Position = UDim2.new(0,0,0,0)

local imagelabel1 = Instance.new("ImageLabel") 
imagelabel1.Parent = frame
imagelabel1.BorderSizePixel = 0
imagelabel1.Size = UDim2.new(0.5,0,1,0)
imagelabel1.ZIndex = 1
imagelabel1.Position = UDim2.new(0.5,0,0,0)

--Iterate through table
for i,v in ipairs(images) do --ipairs iterates in order
    imagelabel.Image = v
end

--Iterate through table
for i,b in ipairs(images) do --ipairs iterates in order
    imagelabel1.Image = b
end

local count = 0

while game.ContentProvider.RequestQueueSize > 0  do
    textlabel.Text = "I'm all fired up!" .. string.rep(".",count)
    count = (count + 1) % 4
    wait(10) 
end

screen.Parent = nil

I hope you can understand what I mean.

1 comment

0

Actually, I'm pretty sure ROBLOX updated the decal limit to 1024x1024, and stopped resizing everything between that and 256x256. I'll look at your code for now, though.

1 answer

✓ Accepted answer

The problem is with the two loops:

--Iterate through table
for i,v in ipairs(images) do --ipairs iterates in order
    imagelabel.Image = v
end

--Iterate through table
for i,b in ipairs(images) do --ipairs iterates in order
    imagelabel1.Image = b
end

What these loops will actually do is set both images to be the last image in the list!

To fix this, it's easiest to assign them directly:

imagelabel.Image = images[1]
imagelabel1.Image = images[2]

Assuming you want to use a variable number of images, it would be better to create the images themselves in a loop, assigning the Image property as you go:

for i, v in ipairs(images) do
	local imagelabel = Instance.new("ImageLabel") 
	imagelabel.Parent = frame
	imagelabel.BorderSizePixel = 0
	imagelabel.Size = UDim2.new(0.5,0,1,0)
	imagelabel.ZIndex = 1
	imagelabel.Position = UDim2.new(0,0,0,0)

	imagelabel.Name = "Image" .. i
	imagelabel.Image = v
end

1 comment

0

thx

This discussion is preserved as it was. New answers, comments, and votes are closed.