Title screen disclaimer not disappearing most of the time after pressing any key to continue

Hello, I am currently trying to make a title screen for my game, when you first join you get a disclaimer, you then press any button to continue once the game is done loading.

But sometimes when you press any button on the disclaimer part it does not continue, and you can only fix this by resetting, which I don’t want. Here’s a video of it not working and working.

Edit: forgot to say that it’s a local script in a StarterGui
Here’s a bit of code from the title screen that could be a part of the issue

if not game:IsLoaded() then
	game.Loaded:Wait()
end
---
---
---
---
game:GetService("UserInputService").InputBegan:Connect(function(iobj, gp)
	if gp then return end --if they are typing in a textbox or something
	if iobj.KeyCode ~= Enum.KeyCode.Unknown then

Also here’s where the script is in
image
I have no idea why this is happening so it would be helpful if someone knows the issue

What script is this in, server or local?

it is a local script, I should have specified that its also in a StarterGui

The local script is in “StarterGui”?

Its in a GUI that’s in StarterGUI, here
image

Weird it’s not working. Try to check your code and the Gui again. You may need to get RemoteEvents too.

Good point, will try doing that. I might need to use remove events for that

1 Like

I noticed that sometimes game.Loaded doesn’t fire for me, which may be the case here. To combat this, I add a timeout wait for the event using this function:

function EventWaitTimeout(event,timeout)
	local done = false
	coroutine.wrap(function()
		event:Wait()
		done = true
	end)()
	local rs = game:GetService("RunService")
	local elapsed = tick()
	while not done and tick()-elapsed < timeout do
		rs.Stepped:Wait()
	end
	--print(done and "Event first" or "Timeout")
end

I will normally set the timeout to 15 seconds, but it’s up to you.

1 Like

Hm, user input service only works in the starter character. maybe that’s the problem?

Where did you get “user input service only works in the starter character” concept from? UserInputService works on all LocalScripts.

I meant starter character or starter player. Then I realized the local script is in the starter gui

1 Like

Thank you, I tried this and it did fix it, thank you for the help!