Script That Shows A GUI After The Game Loads

My bad, should be this code:

local DonateGUI = script.Parent
if not game:IsLoaded() then -- If the game isn't loaded yet,
  game.Loaded:Wait()        -- then wait for it to load
end

DonateGUI.Enabled = true -- Make the GUI visible
wait(5) -- Keep the GUI open for 5 seconds
DonateGUI.Enabled = false -- Make the GUI invisible

Wait, you don’t even need anythign using IsLoaded and what not if it’s outside of replicatedFirst, localscritps do not run unless the game is fully loaded outside of ReplicatedFirst

So in that case, can’t you just do

local donateGui = script.Parent
donateGui.Enabled = true

Edit: Forgot I was replying to another person, meant for it to be directed to @ItsKoolPlayz

So the script would need to be in the ScreenGui, and be that script?

Either way works, if the documentation says that then that’s probably correct and my code is redundant. But nevertheless, either way works.

Localscript in the DonateGui mhm, it’ll run when the game loads for the client, using the Loaded and IsLoaded stuff is only really for custom Loading Screens I believe, as that’s waht the documentation gives an example

EDIT: Enabled NOT Visible, I accidentally wrote .Visible instead of .Enabled, sorry about that, it’s 9:35pm here

It’s ok! The loading screen I have is custom. :thinking: Would that be the problem, and if it is there a solution to it?

Edit: Would you like me to send you the models to both the DonateGui, and the loading screen so you can figure the solution to it having the models too?

This should help

Oh you’re using a custom loading screen? IsLoaded has an example as to how you could do, and the article @adrrob1002 mentioned as well. But generally it involves you either creating it yourself with a script or just cloning it

Would you like me to send you the models to both the DonateGui, and the loading screen so you can figure the solution to it having the models too? Note: The logo on the loading screen is not mine, I just haven’t made my own yet!

I think the articles we sent you should be good to explain to you what you could need, I’m not sure how much I can help since it’s late for me

Oh! So maybe I have to use bool to make the script work?

Try something like this in a localscript in ReplicatedFirst? And put the DonateGui ScreenGui in ReplicatedFirst as well

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
 
local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

local loadingGui = ReplicatedFirst.DonateGUI:Clone()

loadingGui.Parent = playerGui

ReplicatedFirst:RemoveDefaultLoadingScreen()

if not game:IsLoaded() then
	game.Loaded:Wait()
end
loadingGui:Destroy()

I would guess the ScreenGui has to be in the script?

Put it in ReplicatedFirst as that’s how I did it in this eaxmple

That kinda fixed it, although instead of showing the Gui after its loaded, it just removed the Gui out of existence…

Remove the last line I did, the loadingGui:Destroy() line if you want it to stay

That fixed the Gui’s, but now it doesn’t prompt purchase (when I click any of the DonationGui’s)…

Did you remember to put code into the buttons to make it prompt the purchases? What in your ScreenGui?

Yes, Here’s the Prompt Purchase script!

id = 962942854 --Dev Product ID Here

script.Parent.MouseButton1Click:connect(function()

game.MarketplaceService:PromptProductPurchase(script.Parent.Parent.Parent.Parent, id)

end)

You could maybe make it so the localscripts are first disabled and then once it’s done loading they get enabled?

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
 
local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

local loadingGui = ReplicatedFirst.DonateGUI:Clone()

loadingGui.Parent = playerGui

ReplicatedFirst:RemoveDefaultLoadingScreen()

if not game:IsLoaded() then
	game.Loaded:Wait()
end
for _,thing in pairs(loadingGui:GetDescendants()) do
	if thing.ClassName ~= "LocalScript" then continue end
	thing.Disabled = false
end)
1 Like