Help needed with TouchTap

Hello, I’m currently making a system where you press 2 keyboard keys at once, which is currently placed in a loop. I’ve been using both ContextActionService and UserInputService so I can have PC players press the keys on their own keyboard and mobile players tap the keys on the GUI. I have no trouble with pressing the keys on my own keyboard, but I can’t get TouchTap to work.

LocalScript placed in GUI:

local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")

local TimeLeft = script.Value.Value
local Teller = script.Parent.Teller
local Choose = true
local _Choose2 = false
local helpChoose3 = false
local letterchosen = nil
local _letterchosen2 = nil
local Truck = workspace:WaitForChild("Truck")

while task.wait(0.1) do

	if Choose then
		letterchosen = string.char(math.random(string.byte('A'), string.byte('Z')))
		_letterchosen2 = string.char(math.random(string.byte('A'), string.byte('Z')))
		print(letterchosen)
		print(_letterchosen2)
		if _letterchosen2 == letterchosen then
			Choose = true
		else
			Choose = false
		end
	end
	
	local Key = script.Parent:FindFirstChild(letterchosen) 
	local _Key2 = script.Parent:FindFirstChild(_letterchosen2) 
	Teller.TextLabel.Text = "Press " ..letterchosen .. " and " .._letterchosen2
	Key.BackgroundColor = BrickColor.new("Gold")
	_Key2.BackgroundColor = BrickColor.new("Gold")

	--There was code here for the PC, works fine.
	
	local function onTouchTap()
		if not Choose then
			Key.BackgroundColor3 = Color3.fromRGB(130, 130, 130)
			_Choose2 = true
			print("woo")
		end
	end
	
	local function _onTouchTap2()
		if not Choose then
			Key.BackgroundColor3 = Color3.fromRGB(130, 130, 130)
			helpChoose3 = true
			print("woo")
		end
	end
	
	if _Choose2 and helpChoose3 then
		Choose = true
	end
	
	Key.TouchTap:Connect(onTouchTap)
	_Key2.TouchTap:Connect(_onTouchTap2)
end

I’ve just decided to use MouseButton1Down for the mobile players.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.