I’m about to finish my first game (hooray!) but have noticed that a local script I have in StarterGui runs in studio but not in game.
Script:
local starterGui = game:GetService("StarterGui")
starterGui:SetCore("ResetButtonCallback", false)
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
Everything within this script never runs in game. Any suggestions?
L_3ee
(Lee)
April 17, 2020, 3:05pm
#2
Where is the script placed in the game?
Never mind: You need to make a wait(1) before setting it.
It isn’t be initilized but the Script to set it is being first causing an error.
Here:
wait(1)
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
1 Like
I’m just curious, what script would be causing the error? I would like to wait for that to load instead of setting a fixed wait time.
ekuz0diaa
(ekuz0diaa)
April 17, 2020, 3:38pm
#5
Also make sure it isn’t a uncommitted draft.
1 Seconds or even 0.5 seconds should be enough for them to load.
And you can’t really use :WaitForChild() to wait for a Service. So 0.5 or 1 second is enough for them to be found.
(I also believe when the script runs the player is still loading so 1 second should be plenty)
You can use pcall multiple times until it it has been registered:
Pseudocode:
repeat
local success, _ = pcall(function()
StarterGui:SetCore("ResetButtonCallback", false)
end)
wait()
until success
1 Like