Hello I am making a Gui, So I want it so that you can press the button for mobile and press a key for PC. but I can't get them both to work

local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.P then -- The key press function 

and the click detector

script.Parent.MouseButton1Click:Connect(function() --Click detector

I tried combining them both together but it doesn't work unfortuanly any Help is appreciated

1 comment

0

Try using an if statement for PC an then right after that do an elseif for if your on mobile. Also, for mobile you don't use MouseButton1Click you use TouchTap