What's the best way to disable a player's movement until he exit the shop?

Recently i have been busy with a shop but i’m getting confused on how to disable the player’s control if they touch the part? and if possible how to enable them again after pressing the “X” button on the shop GUI?

For more info check the screenshots below to give you a visual on what i mean.

Thanks for reading and wish everyone a nice day!

Picture of the path that should remove the player from walking:

picture of the GUI with the “X” button in which should enable player movement after being pressed:

How it currently works (without disabling player movement when equiping the shop GUI):

Try just setting the LocalPlayer’s MovementSpeed and JumpPower to 0.

1 Like

You can use the following code to enable/disable player movement:

local controls = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule.ControlModule)
controls:Disable()
--or
controls:Enable()
1 Like

Ye i did try the following:
require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls():Enabled()

But i couldn’t get it to work with the ontouch path and the GUI that can be closed

I see. And I apologize for getting that require wrong. You can also use ContextActionService to unbind player movement.

1 Like

Nah, it’s alright you’re just trying to help as well as i haven’t really heard of the ContextActionService but wouldn’t it be better to make a second local to enable it back and how do you that?

Good alternative instead of using require but wouldn’t that be easy exploitable as the player can just exploit to change his movement speed?

What’s the advantage of being able to move while having the shop gui open?

Well I mean, if it is exploited I dont think many people will care.

Like, who cares if he is moving while he is in the shop lol

What if you simply anchored the player’s torso?

You know that’s not actually such a bad idea

Same as anchoring you can basically walk to the spot where you wish to earn fishes (as example) and with the gui still on you that means you can sell them instant instead of going to the actual shop to get the GUI again.

Same as anchoring you can basically walk to the spot where you wish to earn fishes (as example) and with the gui still on you that means you can sell them instant instead of going to the actual shop to get the GUI again. But i keep the idea in mind as it is not such of a bad idea.

A simple serversided distance check would do the trick. Any kind of client side movement lock is not reliable against exploiters.