Gday lads. I’ve tried to make a loading screen that counts the assets, says “Assets Loaded.” and then the GUI transparency fades to 1 before being destroyed. However i get the “Unable to cast to Dictionary” text. If someone could provide some explanation and possible solution, I’d be eternally grateful.
Here is the script that I’ve fiddled around with (everything worked until I added the tweening stuff):
local ReplicatedFirst = game:GetService('ReplicatedFirst')
local ContentProvider = game:GetService("ContentProvider")
-- tweening stuff
local TweenService = game:GetService("TweenService")
local UIObjects = {
script.Parent.LoadingText,
script.Parent.LoadingText.Textbox
}
local Tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false)
local Tween = TweenService:Create(
UIObjects,
TweenInfo ,
{script.Parent.LoadingText.BackgroundTransparency == 1 , script.Parent.LoadingText.Textbox.TextTransparency == 1}
)
local Assets = game:GetDescendants()
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
repeat wait() until game:IsLoaded()
for i = 1, #Assets do
local asset = Assets[i]
ContentProvider:PreloadAsync({asset})
script.Parent.LoadingText.Textbox.Text = "Loading: "..asset.Name.." ["..i.."/"..#Assets.."]"
end
print("Done loading.")
script.Parent.LoadingText.Textbox.Text = "Assets Loaded!"
wait(3)
Tween:Play()
I removed the Delete() action since I thought that might be the problem.
Firstly, I’m not entirely sure that you can tween multiple objects at once like that
Secondly, you need to put just BackgroundTransparency = 1, instead of script.Parent.Loading.Text.BackgroundTransparency = 1. You only put the property name and the value
also I don’t think you put == and you put = instead when setting a value for the properties @SeargentAUS got to it first but this is just the code that I think might fix it.
I think why it was giving you that error because you made the tweeninfo variable name Tweeninfo, but then you use it later as TweenInfo, with a capital i instead, and it didn’t throw an error in the editor, because putting just TweenInfo doesn’t do that. That solved the error with the dictionary.
But after doing that, another error comes up that I am trying to fix currently.
I did it!
Here is the revised script, works perfectly for me.
local ReplicatedFirst = game:GetService('ReplicatedFirst')
local ContentProvider = game:GetService("ContentProvider")
-- tweening stuff
local TweenService = game:GetService("TweenService")
local UIObjects = {
script.Parent.LoadingText,
script.Parent.LoadingText.Textbox
}
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false)
local Assets = game:GetDescendants()
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
repeat wait() until game:IsLoaded()
for i = 1, #Assets do
local asset = Assets[i]
ContentProvider:PreloadAsync({asset})
script.Parent.LoadingText.Textbox.Text = "Loading: "..asset.Name.." ["..i.."/"..#Assets.."]"
end
print("Done loading.")
script.Parent.LoadingText.Textbox.Text = "Assets Loaded!"
wait(3)
for _, v in ipairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
local Tween = TweenService:Create(v, tweenInfo, {BackgroundTransparency = 1}):Play()
else if v:IsA("TextLabel") then
local Tween = TweenService:Create(v, tweenInfo, {BackgroundTransparency = 1 , TextTransparency = 1}):Play()
end
end
end
I tried it out, it said it was loading the name of the asset, and then after, it faded away. It looks pretty good