Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI Script not disabling after being called from another script?

This may be complex. I'm trying to get this GUI script to be disabled until another script inside StarterGui is disabled. The problem is, whenever the script is disabled after I called the Disabled event, it prints "Waiting for the main script to be disabled" twice after MainbarScript is disabled.

EDIT: Fixed.

local MainBarScript = script.Parent:WaitForChild("MainBarScript")
---------------
local MGameText = script.Parent.MinigameGUI.MiniFrame.MinigameText
---------------
local MGameObject = script.Parent.MinigameGUI.MiniFrame.MinigameObj
---------------
local MGameCreator = script.Parent.MinigameGUI.MiniFrame.MinigameCreator
---------------
local MiniFrame = script.Parent.MinigameGUI.MiniFrame
---------------------------------------
--MINIGAMES FOLDER INFO--
local Minigames = game.ReplicatedStorage.Minigames:GetChildren()
---------------------------------------
if game.StarterGui.MainBarScript.Disabled == false then
	print("Waiting for the main script to be disabled")
elseif game.StarterGui.MainBarScript.Disabled == true then
	print("The main script is disabled. Ready to go.")
end

1 comment

0

Could we see what triggers the script to Disable?

1 answer

local MainBar = script.Parent:WaitForChild("MainBar")
---------------
local MainBarFrame = script.Parent.MainBar:WaitForChild("MainBarFrame")
---------------
local MainBarText = script.Parent.MainBar.MainBarFrame:WaitForChild("MainBarText")
---------------
local MinigameGUIScript = script.Parent:WaitForChild("MinigameGUIScript")
---------------
local LobbyMusic = game.workspace:WaitForChild("LobbyMusic")
---------------------------------------
while wait(1) do
	
for i = 1,25 do -- Let the LobbyMusic fade in
	MinigameGUIScript.Disabled = true
	LobbyMusic:Play()
	LobbyMusic.Volume = i*0.04
	wait(0.03)
end

MainBarText.Text = "A minigame will begin shortly"

wait(2)

for i = 15,0,-1 do
MainBarText.Text = "Next minigame will be chosen in " .. i .. " seconds"
wait(1)
---------------
if i == 0 then
LobbyMusic:Pause()
MainBarFrame.Visible = false
script.Disabled = true
MinigameGUIScript.Disabled = false
		end
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.