Disable movement, and any interactions before pressing the Play button

Hi guys! So I’d like to make a script, which disables the player from any interactions, and after pressing on the Play button, the player will able to move, will able to equip tools again. And the StarterPlayer → CameraMode will get a LockFirstPerson value.

Here’s my script:

local p = script.Parent.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
	p.Team = game:GetService("Teams").Red
	p:LoadCharacter()
	
	wait(3)
	script.Parent.Parent.Parent.Enabled = false
end)

Thanks for your help! :slight_smile:

To disable any player action/movement it would be something like this (in a local script)

Y


local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
local Camera = workspace.CurrentCamera
Controls:Disable()
Camera.CameraType = Enum.CameraType.Fixed 
— this should disable character movement and the ability to move around with your camera

To enable. Everything again it would be something like this

Controls:Enable()
Camera.CameraType = Enum.CameraTpye.Custom

I haven’t tested this so there may be some typos!

And this goes into the localscript from which I copied a piece of code? (shown above)

The code should go in a local script. (If the one above is a local script then yes)

1 Like

And what if its not a localscript?
image

Then you would have to use a remote event to do it

Put a remote event in replicated storage and do this

In a local script In starter character scripts do


local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
local Camera = workspace.CurrentCamera

local RM = game.ReplicatedStorage.RemoteEvent


RM.OnClientEvent:Connect(function(instruction)

if instruction == “DisableControls” then
 Controls:Disable()
Camera.CameraType = Enum.CameraType.Fixed

elseif instruction == “EnableControls” then

Controls:Enable()
 Camera.CameraType = Enum.CameraType.Custom
       end
end)

Now in your server script do

—if you want it to be disabled:
local RM = game.ReplicatedStorage.RemoteEvent

RM:FireClient(p,”EnableControls”)

— if you want to disable

Rm:FireClient(p,”DisableControls”)


This is more practical because now you can do this in any server script if you need to disable their controls

1 Like

Thanks for your answer, can I add you on discord, if its not a problem?

Here’s my discord: ati#1509