How do i make attack work for input and click

So im tyring to make a skill system but im not sure how im going to do it for mobile. On mobile they have to click a gui like dungeon quest but idk how im going to do it, can someone help me?

local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage")
local st = game:GetService("StarterGui")
local detroit = rp.Events:WaitForChild("Skill1")
local cam = rp.Events:WaitForChild("Camm")
local UIS = game:GetService("UserInputService")
local debounce = false
local player = game:GetService("Players").LocalPlayer
local value = player:WaitForChild("Cooldown")
local gui = game.StarterGui.MainGui.HUD.SkillsHolder.Slot1.CooldownE

local cooldown = script.Parent.Values.Cooldown.Value

function cameraShake()
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	
	for i=1, 30 do
		local a = math.random(-10,10)/100
		local b = math.random(-10,10)/100
		local c = math.random(-10,10)/100
		
		Humanoid.CameraOffset = Vector3.new(a,b,c)
		
		wait()
	end
	Humanoid.CameraOffset = Vector3.new(0,0,0)
end


UIS.InputBegan:Connect(function(input,isTyping)
	if script.Parent.Values.Equipped.Value == true then
		if isTyping then
			return
				elseif input.UserInputType == Enum.UserInputType.MouseButton1 or input.KeyCode == Enum.KeyCode.E then
			if debounce == false then

				debounce = true
				detroit:FireServer()
			end
		end
	end
end)

detroit.OnClientEvent:Connect(function()
	wait(cooldown)
	debounce = false
end)

cam.OnClientEvent:Connect(function()
	cameraShake()
end)
1 Like

ContextActionService, one of it’s parameters is a bool value for making a button for mobile devices

CAS:BindAction("ActionName", ActionFunction, MakeButton, input, input, input)
1 Like

i already made a gui, im just trying to figure out how to either input e on pc and click the gui on mobile

make the gui only show up on mobile, then have the guiButton do something like GuiObject | Documentation - Roblox Creator Hub

so would it look like ?

elseif script.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot1.TouchTap or input.KeyCode == Enum.KeyCode.E then

TouchTap is an event, not a boolean

script.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot1.TouchTap:Connect(function()
   -- function to use the skill
end)

TouchTap is an event. you would need to listen for it like what you would do on UIS.InputBegan

i don’t really understand like this?

local Player = game:GetService("Players").LocalPlayer

local rp = game:GetService("ReplicatedStorage")
local st = game:GetService("StarterGui")
local detroit = rp.Events:WaitForChild("Skill1")
local cam = rp.Events:WaitForChild("Camm")
local UIS = game:GetService("UserInputService")
local debounce = false
local player = game:GetService("Players").LocalPlayer
local value = player:WaitForChild("Cooldown")
local gui = game.StarterGui.MainGui.HUD.SkillsHolder.Slot1.CooldownE

local cooldown = script.Parent.Values.Cooldown.Value

function cameraShake()
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	
	for i=1, 30 do
		local a = math.random(-10,10)/100
		local b = math.random(-10,10)/100
		local c = math.random(-10,10)/100
		
		Humanoid.CameraOffset = Vector3.new(a,b,c)
		
		wait()
	end
	Humanoid.CameraOffset = Vector3.new(0,0,0)
end


UIS.InputBegan:Connect(function(input,isTyping)
	if script.Parent.Values.Equipped.Value == true then
		if isTyping then
			return
				elseif  input.KeyCode == Enum.KeyCode.E then
			if debounce == false then

				debounce = true
				detroit:FireServer()
			end
		end
	end
end)

detroit.OnClientEvent:Connect(function()
	wait(cooldown)
	debounce = false
end)

cam.OnClientEvent:Connect(function()
	cameraShake()
end)

script.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot1.TouchTap:Connect(function()
	detroit:FireServer()
end)
script.Parent.Parent.Parent.Parent.Parent.HUD.SkillsHolder.Slot1.TouchTap:Connect(function()
    if not debounce and script.Parent.Values.Equipped.Value then
       debounce = true
	   detroit:FireServer()
    end
end)

It’s basically the same thing you did with UIS.InputBegan, it just doesn’t check for a keycode

Yes

i put that at the bottom right?

1 Like