Auto-rejoin not working

After 19 minutes, I want the player to rejoin after 19 minutes, but I’m having a tough time detecting when the player has no input for 19 minutes, it fires a remote. There’s a value always true in my table, stopping it from continuing. Heres the code:

local timer = 0;
local maxTime = 5;
local UIS = game:GetService("UserInputService")
local remote = game.ReplicatedStorage.Events["Auto Rejoin"];
local Enums = {};

UIS.InputBegan:Connect(function(input, GP)
	if input then
		Enums[input] = true;
		print(typeof(input))
		timer = 0
	else
		warn("No input detected from UIS.InputBegan")
	end
end)

UIS.InputEnded:Connect(function(input, GP)
	if input then
		Enums[input] = false;
		print("INPUT ENDED")
	else
		warn("No input detected from UIS.InputEnded")
	end
end)

local function checkEnums()
	print(Enums)
	for enumType, boolean in pairs(Enums) do
		if boolean ~= false then
			timer = 0
			return false;
		end
	end
	return false;
end

while task.wait(1) do
	checkEnums();
	if timer >= maxTime then
		remote:FireServer();
		timer = 0;
		print("Player needs rejoining!")
	else
		timer += 1;
	end
end
1 Like

I think a better way of doing this might be just to reset a timer whenever an input ends. You wont need to store all the inputs that way.

That’s a good point. I thought since the input never actually ends, the timer never restarts though, but I guess it’ll work for now.

1 Like

You could just reset the timer every time an input starts and ends. I’m pretty sure that even if there is an input (for example, you put a heavy object on your left mouse button) Roblox still kicks you. Setting it up to detect changes in input will probably be more consistent.

So, after it starts, I set timer to 0, and at inputended i do aswell? Just trying to make sure I do this right

1 Like

yeah, that should work. If it doesn’t and some input is still changing, just print out the input and make the if statement ignore that specific input