Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't my image labels show the picture?

Asked by 8 years ago
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(255,255,255)
frame.Transparency = 0

local textlabel = Instance.new("TextLabel")
textlabel.Parent = screen
textlabel.BackgroundColor3 = Color3.new(255,255,255)
textlabel.BackgroundTransparency = 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.Size = UDim2.new(0.25,0,0.5,0)
imagelabel.ZIndex = 2
imagelabel.Position = UDim2.new(0.4,0,0.1,0)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429534" -- 1
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429621" -- 2
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429697" -- 3
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429797" -- 4
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429863" -- 5
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429880" -- 6
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429916" -- 7
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265429966" -- 8
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265430040" -- 9
wait(0.05)
imagelabel.Image = "http://www.roblox.com/asset/?id=265430128" -- 10


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

What I believe is the issue is that the images can't load that fast so it causes the image not to appear. Well I changed the value to 2 and it still remained the same. The image label had no picture.

Error: 15:28:27.547 - Image failed to load: http://www.roblox.com/asset/?id=265429534: Failed to resolve texture format 15:28:29.100 - Image failed to load: http://www.roblox.com/asset/?id=265430128: Failed to resolve texture format 15:28:29.181 - Image failed to load: http://www.roblox.com/asset/?id=265429697: Failed to resolve texture format 15:28:29.246 - Image failed to load: http://www.roblox.com/asset/?id=265429916: Failed to resolve texture format 15:28:29.249 - Image failed to load: http://www.roblox.com/asset/?id=265429880: Failed to resolve texture format 15:28:29.415 - Image failed to load: http://www.roblox.com/asset/?id=265429797: Failed to resolve texture format 15:28:29.432 - Image failed to load: http://www.roblox.com/asset/?id=265429863: Failed to resolve texture format 15:28:29.634 - Image failed to load: http://www.roblox.com/asset/?id=265430040: Failed to resolve texture format 15:28:29.924 - Image failed to load: http://www.roblox.com/asset/?id=265429966: Failed to resolve texture format 15:28:30.839 - Image failed to load: http://www.roblox.com/asset/?id=265429621: Failed to resolve texture format

0
If you haven't already subtract the last number by 1 and then try. ;D MessorAdmin 598 — 8y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

Your Problem

The yields on lines 32 - 50 are too small for the images to load. You request the image, then change it to the next one before it gets a chance to load.


What You Need To Do

You need to use the Preload function of the ContentProvider service. The Preload function loads assets before they're used, so that once they're used they will have already been loaded.


Notes About Preload

A very important note is that the content is loaded asynchronously, meaning that the code does not wait for the assets to load before continuing to read the rest of the script. Preload does, however, queue the requests.. meaning that no matter what, eventually, the asset will be loaded.

Due to Preload loading asynchronously, you need to take advantage of the RequestQueueSize property of ContentProvider service. This property contains the number of assets that are queued to load. To manipulate this to your uses, you need to use a while loop to wait until this property's value is 0.


Code

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

--Put your images into a table
local images = {
    "http://www.roblox.com/asset/?id=265429534",
    "http://www.roblox.com/asset/?id=265429621",
    "http://www.roblox.com/asset/?id=265429697",
    "http://www.roblox.com/asset/?id=265429797",
    "http://www.roblox.com/asset/?id=265429863",
    "http://www.roblox.com/asset/?id=265429880",
    "http://www.roblox.com/asset/?id=265429916",
    "http://www.roblox.com/asset/?id=265429966",
    "http://www.roblox.com/asset/?id=265430040",
    "http://www.roblox.com/asset/?id=265430128"
}

--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(255,255,255)
frame.Transparency = 0

local textlabel = Instance.new("TextLabel")
textlabel.Parent = screen
textlabel.BackgroundColor3 = Color3.new(255,255,255)
textlabel.BackgroundTransparency = 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.Size = UDim2.new(0.25,0,0.5,0)
imagelabel.ZIndex = 2
imagelabel.Position = UDim2.new(0.4,0,0.1,0)
--Iterate through table
for i,v in ipairs(images) do --ipairs iterates in order
    imagelabel.Image = v
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
0
It did not work. Infact the GUI did not appear. Ill post errors later Relampago1204 73 — 8y
0
Well it kind of works. It only works in studio Relampago1204 73 — 8y
0
Thanks I fixed it I made a small mistake xD Relampago1204 73 — 8y
0
Yay lol Goulstem 8144 — 8y
Ad

Answer this question