Loading GUI doesn't get affected or the function just doesn't work at all

i have a loading screen, yay!

but it doesn’t really work, no!

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

local contentProvider = game:GetService("ContentProvider")
local rStorage = game:GetService("ReplicatedStorage")
local tService = game:GetService("TweenService")
local tweenParameters = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out
)

-- Path to bindable event;
local events = rStorage:WaitForChild("Events")
local bindableEvents = events:WaitForChild("Bindable")

-- Event;
local menuOnLoad = bindableEvents:WaitForChild("MenuOnLoad")

local ui = script:WaitForChild("LoadingScreen"):Clone()

local assets = game:GetDescendants()

local plr = game:GetService("Players").LocalPlayer
plr.CameraMode = Enum.CameraMode.LockFirstPerson
local plrGui = plr.PlayerGui

ui.Parent = plrGui

local quotes = ui:WaitForChild("Quotes")
local frame = ui:WaitForChild("Frame")
local icon = ui:WaitForChild("Icon")

local quoteChances = {
	["I rebel, therefore I exist."] = 10,
	["Question everything."] = 10,
	["Live fast, die young."] = 10,
	["We are all mad here."] = 10,
	["I am the storm."] = 9,
	["Normal is boring."] = 10,
	["Reality is a prison."] = 10,
	["Die with memories, not dreams."] = 10,
	["Embrace the chaos."] = 10,
	["Silence is the loudest scream."] = 10,
	["Peepee Poopoo."] = 1
}

function SelectQuote()
	local totalChance = 0
	for _,chance in pairs(quoteChances) do
		totalChance += chance
	end

	local rng = math.random(1,totalChance)

	for quote, chance in pairs(quoteChances) do
		rng -= chance
		if rng <= 0 then
			print(quote) -- this does NOT print, and the text stays as "Label"
			return quote
		end
	end
end

if not game:IsLoaded() then
	plr:SetAttribute("Loaded", false)

	coroutine.wrap(function()
		while not game:IsLoaded() do
			quotes.Text = SelectQuote()
			task.wait(5)
		end
	end)()

	local success, err = pcall(function()
		contentProvider:PreloadAsync(assets)
	end)

	if not success then
		warn("Failed to preload asset: " .. err)
	end
end

task.wait(1)

plrGui:WaitForChild("MainMenu").Enabled = true

local frameTween = tService:Create(frame, tweenParameters, {BackgroundTransparency = 1})
local iconTween =tService:Create(icon, tweenParameters, {ImageTransparency = 1})
local quotesTween = tService:Create(quotes, tweenParameters, {TextTransparency = 1})

frameTween:Play()
iconTween:Play()
quotesTween:Play()

frameTween.Completed:Wait()

ui:Destroy()
plr:SetAttribute("Loaded", true)
menuOnLoad:Fire()
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)

image

1 Like

Could you be more specific and tell what is the error or what is happening, and did you check the output if you have any errors?

the quotes text isn’t changing, i do some rng shenanigans every 5 seconds and switch quotes, but for some reason the print inside the function doesn’t run

so the quotes text als odoesn’t change at all, so it stays as Label (Very annoying!)

there is absolutely no errors in the output

Try adding more prints in the SelectQuote function like the print(rng) or print the total chance, etc. to check if everything is correct.

uhhh i just had to apply the text first, because the game will always load too quickly, so the quote swapping will never run

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.