Hey everyone! I’m trying to hide the mobile buttons if the player opens a menu, which works fine, but the problem is that when the player is not in mobile, it returns this error: TouchGui is not a valid member of PlayerGui
It really changes nothing, but I would like to get rid of this. I tried using an if Object then
, followed by an else
to check if the object is not existent, but didn’t worked. Here’s the script btw:
--//Mobile Buttons Hider
local inUse = script.Parent.Info.inUse
inUse.Changed:Connect(function()
if inUse.Value == true then
if PlayerGui.TouchGui and PlayerGui.SprintGui then
PlayerGui.TouchGui.TouchControlFrame.Visible = false
PlayerGui.SprintGui.Enabled = false
else --if object doesn't exists
print("Not In Mobile")
end
else
if inUse.Value == false then
if PlayerGui.TouchGui and PlayerGui.SprintGui then
PlayerGui.TouchGui.TouchControlFrame.Visible = true
PlayerGui.SprintGui.Enabled = true
else --if object doesn't exists
print("Not In Mobile")
end
end
end
end)