How to disable all keyboard inputs until it finishes loading?

i got a loading screen script where im trying to disable all player controls so the player will not be able to move or press other keys that open other stuff.

i’d like to get someones help on this.

local ModuleScript = script.Parent.Parent.Parent.Settings
local Settings = require(ModuleScript)

script.Parent.Parent.Visible = true
script.Parent.Visible = true

local ContentProvider = game:GetService("ContentProvider")
local AssetFolder = Settings.LoadingScreen.AssetFolder:GetDescendants()
local TweenService = game:GetService("TweenService")
local LoadingBarTweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)



if Settings.LoadingScreen.LoadingBar == true then
	script.Parent.LoadingBar.Visible = true
else
	script.Parent.LoadingBar.Visible = false
end

if Settings.LoadingScreen.RandomizedTextEnabled == true then
	script.Parent.RandomizedText.Visible = true
else
	script.Parent.RandomizedText.Visible = false
end

if Settings.LoadingScreen.DefaultRobloxUI == true then
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
else
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
end

script.Parent.Elements.Background.Image = Settings.LoadingScreen.BackgroundImage
script.Parent.Elements.TopText.Text = Settings.LoadingScreen.TopText
script.Parent.Elements.BottomText.Text = Settings.LoadingScreen.BottomText



local LoadAssets = #AssetFolder

for i, v in pairs(AssetFolder) do
	ContentProvider:PreloadAsync({v})
	TweenService:Create(script.Parent.LoadingBar.LoadingBar, LoadingBarTweenInfo, {Size = UDim2.new(i/LoadAssets,0,1,0)}):Play()
end

local GradientTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

TweenService:Create(script.Parent.Parent.UIGradient, GradientTweenInfo, {Offset = Vector2.new(-1,0)}):Play()

print("Assets loaded.")

wait(1)

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

script.Parent.Visible = false
script.Parent.Parent.UIGradient:Destroy()

script.Parent.Parent.Parent:Destroy()
3 Likes

I think the solution to this might be your solution

1 Like

disable the script which handles all of your inputs and do:

repeat task.wait() until game.IsLoaded()
script.Enabled = true
1 Like

Don’t let the character load into the game

Use the PlayerModule module, and do GetControls

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

Controls:Disable() -- Disables controls

Controls:Enable() -- Enables controls

Note: This will not disable UserInputService Just character movements.

1 Like

How to temporarily disable all character input? - #2 by TheGamer101?

Using this will do the exact same thing, as disabling controls.

You could try:

-- Some code used from the quoted post.
ContextActionService:BindAction(
    FREEZE_ACTION,
    function() return Enum.ContextActionResult.Sink end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)
--  And for keycode inputs

ContextActionService:BindAction(
    FREEZE_ACTION,
    function() return Enum.ContextActionResult.Sink end,
    false,
    unpack(Enum.KeyCode:GetEnumItems()))
)

This will disable character controls, and all keyboard inputs.

For other input types, just do unpack(Enum.[UserInputType]:GetEnumItems()

1 Like

for some reason this messed up my tools, like it gets cloned idk how 2 explain

1 Like

Hmm, that’s very unusual. I’d just try disabling controls by doing.

1 Like

im not able to move my player when i try to enabling, and i used what you told me

Show me your code, I need more information.

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


scriptToDisable.Disabled = true

Controls:Disable() -- Disables controls

if Settings.LoadingScreen.LoadingBar == true then
	script.Parent.LoadingBar.Visible = true
else
	script.Parent.LoadingBar.Visible = false
end

if Settings.LoadingScreen.RandomizedTextEnabled == true then
	script.Parent.RandomizedText.Visible = true
else
	script.Parent.RandomizedText.Visible = false
end

if Settings.LoadingScreen.DefaultRobloxUI == true then
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
else
	game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
end

script.Parent.Elements.Background.Image = Settings.LoadingScreen.BackgroundImage
script.Parent.Elements.TopText.Text = Settings.LoadingScreen.TopText
script.Parent.Elements.BottomText.Text = Settings.LoadingScreen.BottomText

-- LOAD THE EXPERIENCE

local LoadAssets = #AssetFolder

for i, v in pairs(AssetFolder) do
	ContentProvider:PreloadAsync({v})
	TweenService:Create(script.Parent.LoadingBar.LoadingBar, LoadingBarTweenInfo, {Size = UDim2.new(i/LoadAssets,0,1,0)}):Play()
end

local GradientTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

TweenService:Create(script.Parent.Parent.UIGradient, GradientTweenInfo, {Offset = Vector2.new(-1,0)}):Play()

print("Assets loaded.")
Controls:Enable() -- Enables controls
scriptToDisable.Disabled = false

What do you have scriptToDisable defined as?

local scriptToDisable = player.PlayerScripts:FindFirstChild(“AbrirMenu”)

its to disable/enable a script that opens a gui

Okay. Hhmm, and when the thing is done loading do you get the Assets Loaded print, in console?

Yes, and im not able to move

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Interesting, try doing this.

require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls():Enable() instead of Controls:Enable() at the end, maybe the Module is updated.

at the end worked. Will test now the Tool again because i got no clue on why this is happening.

Alright, Hopefully it works! (Char Limit)

image

this is what is happening, do you have any clue? Only happens when disabling/enabling character movement (you can see theres a clone behind the tool of the same tool)

Try running this at the end.
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

1 Like