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

Re-enabling mobile controls doesn't bring back joystick. Why?

Asked by
commag 228 Moderation Voter
1 year ago

I am making a 'pong' minigame and for the sake of the mobile gui not interfering with the game, I disabled the mobile movement controls during the game. This works fine for turning them off, but turning them back on only restores the jump button. Any ideas why? The relevant code is below.

The variables I made for this part of the code:

--Mobile Control Components
local localplr = game.Players.LocalPlayer
local playerscripts = localplr:WaitForChild('PlayerScripts')
local playergui = localplr:WaitForChild('PlayerGui')
local playercontrols = require(playerscripts.PlayerModule):GetControls()
local touchgui = playergui:WaitForChild('TouchGui')

The actual function for turning them on and off:

--Disabling Mobile Control
playercontrols:Disable()
if touchgui then touchgui.Enabled = false end

--Coding Quit Button
local function closeGame()
    playercontrols:Enable()
    if touchgui then touchgui.Enabled = true end
    script.Parent.Parent:Destroy()
end

quit.MouseButton1Click:Connect(closeGame)

Answer this question