How do I make it so the player can't move while loading?

I’m trying to make it so when the loading screen is doing its thing the player can’t move. I tried to look it up on youtube but I didn’t find anything. I don’t want them moving while it’s loading so they don’t end up walking somewhere else, away from spawn.

(Forgot to add that I am a complete noob when it comes to scripting.)

Here is the script.

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local GUI = script.LoadingScreen:Clone()
GUI.Parent = PlayerGui

wait (10)

GUI.Frame:TweenPosition(UDim2.new(0,0,1,0),"InOut","Sine",0.5)
wait(0.5)
GUI:Destroy()
4 Likes

This is the best solution for disabling PlayerActions, using ContextActionService.
Post by TheGamer101:

This is quite simple, the only issue are exploiters, which can change their character’s position through script. There are different ways to stop them, ones less efficient than others, but you could probably make a barrier around the player while they are loading, which teleports them back to the original position when touched.
This is almost a bit extreme, but really depends on how necessary it is for player to stay on one spot while loading according to your game. Why this might not be worth your time? Because while a player is loading, they hardly get a chance to execute exploits successfuly, as objects are not yet loaded.

1 Like

Try this:

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()
PlayerGui:SetTopbarTransparency(0)

local GUI = script.LoadingScreen:Clone()
GUI.Parent = PlayerGui

wait (10)

GUI.Frame:TweenPosition(UDim2.new(0,0,1,0),"InOut","Sine",0.5)
wait(0.5)
GUI:Destroy()
controls:Enable()

You can create a preset humanoid by adding a humanoid inside of the StarterPlayer which is a service.

Just put the player’s WalkSpeed to 0.

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local GUI = script.LoadingScreen:Clone()
GUI.Parent = PlayerGui

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local hum = char:WaitForChild('Humanoid')

hum.WalkSpeed = 0
wait (10)

GUI.Frame:TweenPosition(UDim2.new(0,0,1,0),"InOut","Sine",0.5)
wait(0.5)
GUI:Destroy()
hum.WalkSpeed = 16
1 Like

You can also anchor the humanoid root part, works as well

local playercharacter = game.Players.LocalPlayer.Character

playercharacter.HumanoidRootPart.Anchored = true
1 Like