Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI Script not disabling after being called from another script?

Asked by 8 years ago

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
0
Could we see what triggers the script to Disable? Shawnyg 4330 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
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
Ad

Answer this question