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
I have no idea why this is happening so it would be helpful if someone knows the issue
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.