local vhs = script.Parent
local StaticImages = {
'rbxassetid://120418234923349';
'rbxassetid://136113918166159';
}
while task.wait(0.05) do
script.Parent.Image = StaticImages[math.random(1, #StaticImages)]
vhs.Image = StaticImages[math.random(1, #StaticImages)]
end
This script flickers between 2 VHS overlays but sometimes it just flickers to nothing.
It looks like you called for the Main Overlay twice, maybe try somthing like this or alter your own script:
local vhs = script.Parent:WaitForChild("VHS")
local image1 = "rbxassetid://136113918166159"
local image2 = "rbxassetid://120418234923349"
local images = {image1, image2}
while task.wait(0.3) do
local selectRandom = images[math.random(1, #images)]
vhs.Image = selectRandom
end
local image1 = "rbxassetid://136113918166159"
local image2 = "rbxassetid://120418234923349"
local images = {image1, image2}
while task.wait(0.1) do
local selectRandom = images[math.random(1, #images)]
script.Parent.Image = selectRandom
end
It’s doing the same thing. I’m not sure why its doing that.
Actually just realized that it actually may happen because of that
Try having all images there and just enable and disable them (As Instances, turn their visible value)
(Like disable all images, then enable one and repeat)
you might need to check if the selectRandom is not nil before setting the image:
local image1 = "rbxassetid://136113918166159"
local image2 = "rbxassetid://120418234923349"
local images = {image1, image2}
while task.wait(0.1) do
local selectRandom = images[math.random(1, #images)]
if selectRandom then
script.Parent.Image = selectRandom
end
end
Well i have another thought, i would use ContentProvider Service to load all images before Before starting the loop:
local image1 = "rbxassetid://136113918166159"
local image2 = "rbxassetid://120418234923349"
local images = {image1, image2}
game:GetService("ContentProvider"):PreloadAsync(images)
while task.wait(0.1) do
local selectRandom = images[math.random(1, #images)]
script.Parent.Image = selectRandom
end
Didn’t know you can do that
By the way how I would make actual loading screen to wait till all assets load cuz I don’t know how to get all assets and loaded one’s (Just wanting to know how to get all assets in-game and the loaded ones)
Thats weird, I tried testing it in my own session with the same ID’s and I didnt have that problem. Are there any other GUI elements with seperate scripts under the same ScreenGui?
You could get all paths you want (wouldnt suggest going through the whole game as it will take a while if you have a huge game):
local Paths = {workspace,game:GetService("ReplicatedStorage"),game.Players.LocalPlayer.PlayerGui}
and loop through the table preloading each asset and adding them in pcall to know which asset failed to load and which asset loaded:
for i, asset in ipairs(Paths) do
local success, result = pcall(function()
return game:GetService("ContentProvider"):PreloadAsync({asset})
end)
if not success then
warn("Failed to preload asset:", asset)
end
end
local vhs = script.Parent:WaitForChild("VHS")
local image1 = "rbxassetid://136113918166159"
local image2 = "rbxassetid://120418234923349"
local images = {image1, image2}
while task.wait(0.3) do
local selectRandom = images[math.random(1, #images)]
vhs.Image = selectRandom
end
Yeah this seems to be a common problem. It looks like Roblox removes images from memory sometimes, so it takes a brief moment to load them on to the screen, even when they’re preloaded in some cases.
I would create two separate image labels, then use the ImageLabel.ImageTransparency of the two ImageLabels to flip between the images.