I am trying to make a press any key to continue gui where it’ll disappear after you press literally any key… is that possible?.. if so can anyone help me
I believe the only way you could achieve this is by using the UserInputService.
https://developer.roblox.com/en-us/api-reference/class/UserInputService
You could do this with (UserInputService | Roblox Creator Documentation).
-- We must get the UserInputService before we can use it
local UserInputService = game:GetService("UserInputService")
local function onInputBegan(input, gameProcessed)
--Do code
end
UserInputService.InputBegan:Connect(onInputBegan)
Please, don’t use plr:GetMouse(), it is highly recommended to use UserInputService and not use Mouse.
local script:
local UIS = game:GetService("UserInputService")
if (UIS.KeyboardEnabled) then
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard and gui.Enabled == true then
gui.Enabled = false
end
if input.UserInputType == Enum.UserInputType.MouseButton1 and gui.Enabled == true then
gui.Enabled = false
end
end)
else
if input.UserInputType == Enum.UserInputType.Touch and gui.Enabled == true then
gui.Enabled = false
end
end
If there are any errors tell me.
@tnt_Dante is close. I would disconnect your event after you get an input.
Also you could use :Wait
to make things easy to use:
local function WaitForAnyKey()
local done = false
local input, gameProcessed
repeat input, gameProcessed = game:GetService("UserInputService").InputBegan:Wait()
if not gameProcessed and input.UserInputType == Enum.UserInputType.Keyboard
or input.UserInputType == Enum.UserInputType.MouseButton1
or input.UserInputType == Enum.UserInputType.Touch then
done = true
end
until done
end
while true do
print("a")
WaitForAnyKey()
print("b")
end
After like awhile of figuring out that… You use playergui instead of startergui tranparency i use this as the solution i am pretty sure the others could’ve possibly worked but this is the one that worked first so thank you
Yes, of course it is possible! In this case you could use the “UserInputService”.
In the following example I have a ScreenGui in the service “Starter Gui” and in the ScreenGui there is a LocalScript, a Frame and a TextLabel.
The following code is in the LocalScript:
local UIS = game:GetService("UserInputService")
local ScreenGui = script.Parent
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode then
ScreenGui.Enabled = false
end
end
end)
I hope that I could help you.
Thanks but i already found a solution