Block Player Movement

Block Player Movement

I am making a game and when I have my loading screen on I don’t want the player to be able to move. How can I do this.

So far I have tried a few things and none worked any help appreciated. All I really need is a simple script to that until players click a button they can’t use any keys to affect the game.

you can just set their humanoid walkspeed to 0.

How can I do that? Is it through like a script or what?

something like this (just an example with my name/player):

game.Players.sniper74will.Character.Humanoid.WalkSpeed = 0

Ok and how do I do that for everyone until they click play?

Would I just use local player?

for i, v in pairs(game.Players:GetChildren()) do
v.Character.Humanoid.WalkSpeed == 0
end

That is for everyone in the game.

he asked on how to do it if they are on a loading screen.

Oh ok, I am sorry. I didnt read my bad.

yes you can do that. WalkSpeed just replicates for everyone.


local buttonclick = script.Parent.MouseButton1Click:Connect(function ()
	game.Players.LocalPlayer.Character.Humanoid.Walkspeed = 10
end)

if buttonclick == false then
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 
else 
	game.Players.LocalPlayer.Character.Humanoid.Walkspeed = 10
end

Thats what I did

I would recommend using a RemoteEvent.

Start by making the play button.
image

Now insert a LocalScript into the play button, like this.

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.PlayEvent:FireServer()
	script.Parent.Visible = false
end)

PlayEvent is a RemoteEvent inside of ReplicatedStorage, so remember to put one in there and name it that or whatever you want as long as you change the script accordingly. Now insert this script into ServerScriptService.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char.Humanoid.WalkSpeed = 0
		game.ReplicatedStorage.PlayEvent.OnServerEvent:Connect(function()
			char.Humanoid.WalkSpeed = 16
		end)
	end)
end)

I tested it and it worked. Hope this helped! If it did, it would be highly appreciated if you marked it as a solution! :wink:

2 Likes

Thanks sooooo much man it works perfectly.

not trying to be rude, but your script won’t work well as if someone new joins and someone still didnt click the button then clicks it, the new person’s walkspeed will be set and not the current player.
Here is what I mean:

game.ReplicatedStorage.PlayEvent.OnServerEvent:Connect(function() --here you change the remote event to the new player's version.
	char.Humanoid.WalkSpeed = 16 --you change the new player's walkspeed.
end)

Instead, do this:

game.ReplicatedStorage.PlayEvent.OnServerEvent:Connect(function(player) --Have this as its own separate script and remove it out of the last script.
	player.Character.Humanoid.WalkSpeed = 16 --change the CURRENT player's walkspeed not the new player's
end)

Thanks for this, I tried to find the issues but yeah I tried multiple way to do it but I didn’t tought about this simple way lol. Thanks again