You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m making a dialogue system in roblox studio, and want to make it so while the dialogue gui is enabled, all other guis are disabled.
What is the issue? Include screenshots / videos if possible!
When the UI is enabled, the others disappear as scripted, but when I disable it they don’t come back.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried searching on the devforum + documentation.
Current Script:
local IsVisible = false
while wait() do
if script.Parent.Dialogue.Enabled then
IsVisible = true
for _, GUI in script.Parent:GetChildren() do
if GUI.Name ~= "Dialogue" then
GUI.Enabled = false
end
end
end
end
if IsVisible and script.Parent.Dialogue.Enabled then
IsVisible = false
for _, GUI in script.Parent:GetChildren() do
if GUI.Name ~= "Dialogue" then
GUI.Enabled = true
end
end
end
-- DialogueHandler LocalScript
local Player = game:GetService("Players").LocalPlayer
local DisabledUIs = {}
wait(5)
Player.PlayerGui.Dialogue.Enabled = true
for _, UIs in Player.PlayerGui:GetChildren() do -- This'll get all the ScreenGui elemets under PlayerGui
if not table.find(DisabledUIs, UIs.Name) and UIs:IsA("ScreenGui") and UIs.Name ~= "Dialogue" then
table.insert(DisabledUIs, UIs.Name) -- This'll handle duplicate prevention & later re-enabled ones that were disabled
UIs.Enabled = false
end
end
wait(5)
Player.PlayerGui.Dialogue.Enabled = false
for _, UIs in Player.PlayerGui:GetChildren() do
if table.find(DisabledUIs, UIs.Name) and UIs:IsA("ScreenGui") and UIs.Name ~= "Dialogue" then
for Index, Items in pairs(DisabledUIs) do
if DisabledUIs == UIs.Name then
table.remove(DisabledUIs, Index)
break
end
end
UIs.Enabled = true
end
end
Edit: This is assuming the UI items you want to disable are ScreenGui’s under the Player’s PlayerGui, you can also use GetDescendants to filter out more.
function ShowUI()
UIFrame.Visible = true
end
function CloseUI()
UIFrame.Visible = false
end
OpenUIButton.Activated:Connect(ShowUI)
CloseUIButton.Activated:Connect(CloseUI)
local IsVisible = false
task.spawn(function()
while wait() do
if script.Parent.Dialogue.Enabled then
IsVisible = true
for _, GUI in script.Parent:GetChildren() do
if GUI.Name ~= "Dialogue" then
GUI.Enabled = false
end
end
end
end
end)
if IsVisible and script.Parent.Dialogue.Enabled then
IsVisible = false
for _, GUI in script.Parent:GetChildren() do
if GUI.Name ~= "Dialogue" then
GUI.Enabled = true
end
end
end
Although all of these work quite well, this one will work best for me now that I think about it. Since I’m going to use remote/bindable events, this will let me easily integrate it into my actual dialogue function. Thanks for the help