Queue system does not work for mobile

Hi! I have a script for a queue, but this only works in Studio and on Roblox PC. On mobile / tablet this does not work. You can then walk through the queue while this is not supposed to happen. You are supposed to be in the queue until the next person has left the queue.

So far I have not been able to find a solution. I thought of ModalEnabled = false, but this does not disable the function so players can still walk freely in the queue.

I hope someone can help me.

Mainscript

local settings = require(script.Parent.Settings)

local currentPlayersInLine = {}

script.Parent.Trigger.ProximityPrompt.Triggered:Connect(function(player)
	local s,r=pcall(function()
		if #currentPlayersInLine < 5 then
			local playerIn = 0
			for i, plrName in pairs(currentPlayersInLine) do
				if plrName == player.Name then
					playerIn = i
				end
			end
			if playerIn ~= 0 then
				table.remove(currentPlayersInLine,playerIn)
				game.ReplicatedStorage.Movement:FireClient(player,true)
			else
				table.insert(currentPlayersInLine,player.Name)
				player.Character:FindFirstChildWhichIsA("Humanoid"):MoveTo(script.Parent.PlayerLocations:FindFirstChild(#currentPlayersInLine).Position)
				game.ReplicatedStorage.Movement:FireClient(player,false)
				game.ReplicatedStorage.EnableQue:FireClient(player,not true)
			end
		end
	end)
	if not s then
		warn(r)
	end
end)

while wait(settings.QueTime) do
	if #currentPlayersInLine > 0 then
		local s, r = pcall(function()
			local playerName = currentPlayersInLine[1]
			local player = game.Players:FindFirstChild(playerName)
			player.Character:FindFirstChildWhichIsA("Humanoid"):MoveTo(script.Parent["end"].Position)
			game.ReplicatedStorage.Movement:FireClient(player,true)
			game.ReplicatedStorage.EnableQue:FireClient(player,not false)

			table.remove(currentPlayersInLine,1)
			for i, playerName in pairs(currentPlayersInLine) do
				local player = game.Players:FindFirstChild(playerName)
				if player then
					player.Character:FindFirstChildWhichIsA("Humanoid"):MoveTo(script.Parent.PlayerLocations:FindFirstChild(i).Position)
				end
			end
		end)
		if not s then
			warn(r)
		end
	end
end

Settings

local settings = {
	["QueTime"] = 30,
	["MaxPlayerCount"] = 10
}

--If you want to add more players, you must make new parts, move them to "PlayerLocations" folder and rename them to the number.

return settings

Explorer