How to make open frame when screen touched?

how to make open frame when screen touched?

You can just use UserInputService for this.

UserInputService.TouchTap:Connect(function()
	frame.Visible = true
end)

TouchTap is only for mobile devices, how to do it for PC

userinputservice.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		frame.Visible = true
	end
end)

dont work:(

local function OpenFrame(frame: Frame)
		if not frame.Visible then
			CloseAllFrame()
			CloseAll()
			Services.TweenService:Create(Camera, TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {FieldOfView = 80}):Play()
			Blur.Visible = true
			frame.Visible = true
			frame.Position = UDim2.fromScale(0.5,0.525)
			Services.TweenService:Create(frame, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.fromScale(0.5,0.5)}):Play()
		else
			Services.UserInputService.InputBegan:Connect(function(input)
				if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
					CloseAllFrame()
					OpenAll()
			end
		end)
	end
end

Its because you’ve got to actually run it.

I just didn’t show

for _, frame in ipairs(FramesFolder:GetChildren()) do
	local button = Left:FindFirstChild(frame.Name)
	button.Button.MouseButton1Click:Connect(function()
		OpenFrame(frame)
	end)
end
1 Like
local UIS = game:GetService("UserInputService")
local function OpenFrame(frame: Frame)
	if not frame.Visible then
		CloseAllFrame()
		CloseAll()
		Services.TweenService:Create(Camera, TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {FieldOfView = 80}):Play()
		Blur.Visible = true
		frame.Visible = true
		frame.Position = UDim2.fromScale(0.5,0.525)
		Services.TweenService:Create(frame, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.fromScale(0.5,0.5)}):Play()
	else
		Services.UserInputService.InputBegan:Connect(function(input)
			if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
				CloseAllFrame()
				OpenAll()
			end
		end)
	end
end

UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Touch then
		OpenFrame("Frame instance goes here")
	elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
		OpenFrame("Frame instance goes here")
	end
end)
1 Like

This also works, without having to add more statements:

local UIS = game:GetService("UserInputService")

local Inputs = {
    Enum.UserInputType.Touch,
    Enum.UserInputType.MouseButton1,
    -- You can add more inputs for the frame to open
}

local function OpenFrame(frame: Frame)
	if not frame.Visible then
		CloseAllFrame()
		CloseAll()
		Services.TweenService:Create(Camera, TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {FieldOfView = 80}):Play()
		Blur.Visible = true
		frame.Visible = true
		frame.Position = UDim2.fromScale(0.5,0.525)
		Services.TweenService:Create(frame, TweenInfo.new(0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {Position = UDim2.fromScale(0.5,0.5)}):Play()
	else
		Services.UserInputService.InputBegan:Connect(function(input)
			if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
				CloseAllFrame()
				OpenAll()
			end
		end)
	end
end

UIS.InputBegan:Connect(function(input)
	if table.find(Inputs, input.UserInputType) then
        OpenFrame("Frame instance goes here")
	end
end)
1 Like

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