Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to disable movement when a gui is visible?

Asked by 2 months ago
Edited 2 months ago

i have been having problems with this code. I want to make it stop an movement of the player when that frame is visible. I tried the script below but if didn't work (i took the movement control script from roblox's devforum). PLease help, thnx ps: I am new so i am bad at scripting

local UIP = game:GetService("UserInputService")

if game.StarterGui.ScreenGui2.Frame.Visible == true then
    if UIP.UserInputType == Enum.UserInputType.Keyboard then
        if UIP.KeyCode == Enum.KeyCode.W and Enum.KeyCode.A and Enum.KeyCode.S and Enum.KeyCode.D then
            local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
            controls:Disable()
        end
    end
end

1 answer

Log in to vote
1
Answered by 2 months ago

Instead of doing the long way, your way. You can always just do when the UI is touched just set the players walkspeed and jumppower to 0. And when you close it just revert their speed and jump.

0
ok but can u give the script? AriyanHacker29 22 — 2mo
0
It is not a request website, you have to write it yourself or give us a code to fix. EH2019SIT 69 — 2mo
Ad

Answer this question