Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to disable movement when a gui is visible?

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

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.

2 comments

0

ok but can u give the script?

0

It is not a request website, you have to write it yourself or give us a code to fix.

This discussion is preserved as it was. New answers, comments, and votes are closed.