TouchGui re-enables itself

I can usually debug and make work arounds on my own, but this is really bugging me right now.

I’m trying to hide the TouchGui once the game is fully loaded (by waiting for game.Loaded event to fire), however as soon as I set it’s Enabled state to false, it almost instantaneously re-enables itself.

Without having to use task.wait or anything hacky like that (if at all possible), what do you guys suggest? Thanks!

Edit after solution: Really no other way other than to call the deprecated function. However I would like to point out that even though the GUI is invisible, they can still control their character. So disable the controls too, as you use this function.

Any code?
Probably something makes the GUI re-enabling itself.

Pretty sure it’s Roblox itself.

if not game:IsLoaded() then game.Loaded:Wait() end

game.Players.LocalPlayer.PlayerGui:WaitForChild('TouchGui').Enabled = false
-- Apparently this isn't working as it re-enables itself
-- i have to either use task.wait() or something before running this code...

This isn’t how I write my code, but its a quick dirty example for the sake of clarity

A better way doing it:

if not game:IsLoaded() then game.Loaded:Wait() end
local UIS = game:GetService("UserInputService")
UIS.ModalEnabled = true

Reference: Article - Roblox.

1 Like

put LocalScript in StarterGui

Hey, just want to make sure did you set the UI bool of: “ResetOnSpawn” to false, because once the character loads it will just re-enable itself.
image

This is the Roblox controlled TouchGui, it’s already to false. Just want to point that out.

1 Like

Ahh, my bad should’ve read the post more.

1 Like

It really wouldnt make a huge difference and I’m trying to control things from modules in PlayerScripts folder (StarterPlayerScripts) just to test things out in new ways of architecture.

Would use that if it wasnt deprecated honestly, I kinda wanna stir away from those, but if its the last choice…

1 Like