Hey Developers,
In my last topic on developer forum i was asking for help. Basically i wanted to make Gui on/off button. But i wanted to aplpy for text buttons only. The problem is when you click the button, the controls on mobile also disappears… Basically jump button is not available and when walking, the camera is moving as well.
The script:
local button = script.Parent
local buttonGui = button.Parent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local guiStates = {}
local guisVisible = true
button.MouseButton1Click:Connect(function()
guisVisible = not guisVisible
for _, gui in pairs(playerGui:GetChildren()) do
if gui:IsA("ScreenGui") and gui ~= buttonGui then
if guisVisible then
gui.Enabled = guiStates[gui] or true
else
guiStates[gui] = gui.Enabled
gui.Enabled = false
end
end
end
end)
Could anyone help me please?
This is kinda emergency, because it makes my experience unplayable.
Thanks in advance
-jeziskrista
1 Like
Can you specify more, and screenshot? This is too vague.
2 Likes
You might just have to list all of the text buttons you want to disappear when you click it. Because the game is also making mobile controls disappear as well.
1 Like
Sure thing, give me few minutes, I’ll make screen recording.
1 Like
Ok so the problem is your disabling the CoreGuis roblox implements already when content is loaded for the player is PlayerGuii.
1 Like
here’s a code that exclude roblox’s coreGui touchGui
local button = script.Parent
local buttonGui = button.Parent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local guiStates = {}
local guisVisible = true
button.MouseButton1Click:Connect(function()
guisVisible = not guisVisible
for _, gui in pairs(playerGui:GetChildren()) do
if gui:IsA("ScreenGui") and gui ~= buttonGui and gui.Name ~= "TouchGui" then
if guisVisible then
gui.Enabled = guiStates[gui] or true
else
guiStates[gui] = gui.Enabled
gui.Enabled = false
end
end
end
end)
1 Like
Your not wrong but he wants to apply to text buttons only
2 Likes
I will try it asap. I will follow up with an update
1 Like
Try this code:
local button = script.Parent
local buttonGui = button.Parent
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local guiStates = {}
local guisVisible = true
button.MouseButton1Click:Connect(function()
guisVisible = not guisVisible
for _, gui in pairs(playerGui:GetDescendants()) do
if gui.Parent:IsA("ScreenGui") and gui.Parent ~= buttonGui and gui.Parent.Name ~= "TouchGui" and gui:IsA("TextButton") then
if guisVisible then
gui.Enabled = guiStates[gui] or true
else
guiStates[gui] = gui.Enabled
gui.Enabled = false
end
end
end
end)
[/quote]
2 Likes
As the guy under you said, i need it to apply for text buttons only. Still thanks for effort!
1 Like
I decided not to say anything cause, he can help out abit. I was just exploring. Good luck with your game.
2 Likes
I’ll try as soon as possible, like in 20 minutes, i need to make something done really quick
1 Like
Alright! Still thanks! I appreciate it a lot!
2 Likes
So sorry, it turned out to be task for longer, but i will test this script as soon as possible. I hope It’s not problem.
-jeziskrista
1 Like
Sadly this script malfunctioned the button totally. Nothing happens when clicked.
1 Like
Sorry for interrupting, but you could still list all of the text buttons that will reappear and disappear. Except for the button that turns off/on the UI. You could also add a cooldown so that it doesn’t break.
2 Likes
Great idea, let me take screenshot really quick.
1 Like
My bad the textbutton has to use visible property
2 Likes