How to make player freeze during intro and unfreeze afterwards?

Hello,

So I’ve made an intro for my game following a tutorial a few days ago and works fine. The thing is that you can still walk while it plays. I was wondering if someone could help me so the player can’t move/freeze in the meantime and unfreeze at the end. It should be pretty simple but since I’m not a scripter…

The code inside the LocalScript:

local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local RemoteEvent = game.ReplicatedStorage.IntroEvent
local intromusic = game.Workspace:FindFirstChild("intromusic")


local ScreenGui = script.Parent
local Frame = ScreenGui:WaitForChild("Frame")
local logo = Frame:WaitForChild("logo")
local presents = Frame:WaitForChild("presents")
local zailpark = Frame:WaitForChild("zailpark")
local warning = Frame:WaitForChild("warning")
local headphones = Frame:WaitForChild("headphones")

Frame.BackgroundTransparency = 0

local FrameInvisible = {}

local LogoVisible = {}
local LogoInvisible = {}

local PresentsVisible = {}
local PresentsInvisible = {}

local ZailParkVisible = {}
local ZailParkInvisible = {}

local WarningVisible = {}
local WarningInvisible = {}

local HeadphonesVisible = {}
local HeadphonesInvisible = {}

FrameInvisible.BackgroundTransparency = 1
LogoVisible.ImageTransparency = 0
LogoInvisible.ImageTransparency = 1
PresentsVisible.ImageTransparency = 0
PresentsInvisible.ImageTransparency = 1
ZailParkVisible.ImageTransparency = 0
ZailParkInvisible.ImageTransparency = 1
WarningVisible.ImageTransparency = 0
WarningInvisible.ImageTransparency = 1
HeadphonesVisible.ImageTransparency = 0
HeadphonesInvisible.ImageTransparency = 1

local Info = TweenInfo.new(2)
local STweenFrameInvisible = TweenService:Create(Frame,Info,FrameInvisible)
local STweenLogoVisible = TweenService:Create(logo,Info,LogoVisible)
local STweenLogoInvisible = TweenService:Create(logo,Info,LogoInvisible)
local STweenPresentsVisible = TweenService:Create(presents,Info,PresentsVisible)
local STweenPresentsInvisible = TweenService:Create(presents,Info,PresentsInvisible)
local STweenZailParkVisible = TweenService:Create(zailpark,Info,ZailParkVisible)
local STweenHeadphonesInvisible = TweenService:Create(headphones,Info,HeadphonesInvisible)

local faster = TweenInfo.new(0)
local FTweenWarningVisible = TweenService:Create(warning,faster,WarningVisible)
local FTweenWarningInvisible = TweenService:Create(warning,faster,WarningInvisible)
local FTweenHeadphonesVisible = TweenService:Create(headphones,faster,HeadphonesVisible)
local FTweenHeadphonesInvisible = TweenService:Create(headphones,faster,HeadphonesInvisible)
local FTweenZailParkInvisible = TweenService:Create(zailpark,faster,ZailParkInvisible)

RemoteEvent.OnClientEvent:Connect(function()
	wait(6)
	intromusic:Play()
	STweenLogoVisible:Play()
	wait(4)
	STweenLogoInvisible:Play()
	wait(0.2)
	STweenPresentsVisible:Play()
	wait(4)
	STweenPresentsInvisible:Play()
	wait(2)
	STweenZailParkVisible:Play()
	wait(4.7)
	warning.ImageTransparency = 0
	wait(7.3)
	headphones.ImageTransparency = 0
	wait(7.45)
	headphones.ImageTransparency = 1
	warning.ImageTransparency = 1
	zailpark.ImageTransparency = 1
	wait(7.4)
	STweenFrameInvisible:Play()
	script.Parent:Destroy()
end)

How would I go about get the player’s humanoid to then be able to change the WalkSpeed to 0 in the meantime? I’ve tried making an ontouch freeze brick and see what I could implement to the LocalScript from it but it didn’t really work out well, also checked the devforums but didn’t find any that was very helpful.

There’s actually a really efficient way of achieving this properly! Roblox of course has a PlayerModule that controls a myriad of things that include movement. :slight_smile:

We can directly employ an :Enable() and :Disable() method of this module:

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

--To disable movement inputs
Controls:Disable()

--To re-enable movement inputs
Controls:Enable(true)
5 Likes

Does not work for me, no errors being printed in console.
Controls successfully become disabled but re-enabling controls is a different story. Players are forever frozen. I’ve been on the forums looking for a solution for a while but nothing is working. How do you unfreeze a player in 2022? I’m using localscript btw

Could you show the code you are currently trying to run?