I'm trying to make a Gui play a small 3 frame GIF as it loads the assets.
I made a function that does this but it's not working, for some reason it doesn't change the value it's supposed to and stays on the first frame.
Here is the code:
local player = game.Players.LocalPlayer
local loaded = false
local screen = script.Parent
local bg = screen:WaitForChild("LoadingBG")
local spinner = bg:WaitForChild("Spinner")
local text = bg:WaitForChild("Percentage")
local frame = game:GetService("RunService").RenderStepped
local cProvider = game:GetService("ContentProvider")
local LoadBG = script.Parent:WaitForChild('LoadingBG')
local loadAssets = {"224916606", --Loading Spinner
--"227793776","227796482", --Item Boxes
"201858144","188242039", --Vehicle Sounds
"31402133", --Checker pattern,
"188304771", --Title theme
"258950712", -- Title image
"229077998","229078044","229078066", '429156109', '429156538', -- Title buttons
'429156414', }
for _,v in pairs(loadAssets) do
cProvider:Preload("rbxassetid://" .. v)
end
wait()
local divideBy = cProvider.RequestQueueSize
function fadeIn()
bg.BackgroundTransparency=0
spinner.ImageTransparency=1
text.TextTransparency=1
for i=1,120 do
LoadBG.GuiVal.Value = LoadBG.GuiVal.Value + 1
spinner.ImageTransparency = 1-i/120
text.TextTransparency = 1-i/120
frame:wait()
end
spinner.ImageTransparency=0
text.TextTransparency=0
end
LoadBG.GuiVal.Changed:connect(function()
LoadBG.GuiVal.Value = LoadBG.GuiVal.Value + 1
if LoadBG.GuiVal.Value > 3 then
LoadBG.GuiVal.Value = 1
elseif LoadBG.GuiVal.Value == 1 then
LoadBG.Spinner.ImageTransparency = 0
print('Changed')
elseif LoadBG.GuiVal == 2 then
LoadBG.Spinner2.ImageTransparency = 0
LoadBG.Spinner.ImageTransparency = 1
print('Changed2')
elseif LoadBG.GuiVal == 3 then
print('Changed3')
LoadBG.Spinner2.ImageTransparency = 1
LoadBG.Spinner3.ImageTransparency = 0
end
end)
function update()
--spinner.Rotation = spinner.Rotation + 1
text.Text = (math.max(0,math.ceil((1-cProvider.RequestQueueSize/divideBy)*100)) .. '%')
if cProvider.RequestQueueSize<1 then
loaded = true
end
frame:wait()
end
LoadBG.GuiVal.Value = LoadBG.GuiVal.Value + 1
repeat update() until loaded== true
local soundX = require(game.ReplicatedStorage.SoundX)
local player=game.Players.LocalPlayer
function fadeOut()
for i=1,120 do
LoadBG.GuiVal.Value = LoadBG.GuiVal.Value + 1
spinner.ImageTransparency = i/120
text.TextTransparency = i/120
frame:wait()
end
local m=soundX.playSong(player,"156020985")
text.Text="Welcome to..."
for i=1,30 do
text.TextTransparency = 1-i/30
frame:wait()
end
wait(2)
for i=1,90 do
text.TextTransparency = i/90
frame:wait()
end
player.PlayerGui.TitleScreen.Frame.Visible=true
player.PlayerGui.TitleScreen.Frame.Panning.Disabled=false
screen:Destroy()
end
fadeOut()
Furthermore, it gives me a error. It says...
14:29:46.310 - Maximum event re-entrancy depth exceeded for IntValue.Changed 14:29:46.311 - While entering function defined in script 'ReplicatedFirst.Load.LoadScreen.LoadScr', line 41 14:29:46.311 - Maximum event re-entrancy depth exceeded for IntValue.Changed 14:29:46.312 - While entering function defined in script 'ReplicatedFirst.Load.LoadScreen.LoadScr', line 41
What does this mean?

3 comments
You have an infinate loop on line 43 e.g. LoadBG.GuiVal.Value = LoadBG.GuiVal.Value + 1 So the code will never stop until you reach the max inVal
My main issue is that it won't change the frame no matter what i do..
http://wiki.roblox.com/index.php?title=Loops#Repeat