How do mobile button for my script?

hi my name is abed and i need help

  1. i want some help i have tool but the tool work only for computer
  2. i want make button like bedwars just one button for attack
  3. the system for the sword i use it free model i wall put the local script for the tool
--|| Services ||--
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

--|| Modules ||--
local AnimationHandler = require(ReplicatedStorage.Modules.Shared.AnimationHandler)

--|| Remotes ||--
local ServerRemote = ReplicatedStorage.Remotes["SwordServer"]

--|| Variables ||--
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Tool = script.Parent
local Equipped = false

--|| Input ||--
Tool.Equipped:Connect(function()
	Equipped = true
	ServerRemote:FireServer("sdarkblade", "Equipped")
	AnimationHandler.PlayAnim("swordequip")
	
	UserInputService.InputBegan:Connect(function(Input,Typing)
		if Typing == false and Input.UserInputType == Enum.UserInputType.MouseButton1   and Equipped then
			ServerRemote:FireServer("sdarkblade", "Sword", "sdarkblade")
		end
	end)
	
	UserInputService.InputBegan:Connect(function(Input,Typing)
		if Typing == false and Input.UserInputType == Enum.UserInputType.llllllllllll and Equipped then
			ServerRemote:FireServer("sdarkblade", "Block", script.Parent.Name)
		end
	end)

end)

Tool.Unequipped:Connect(function()
	ServerRemote:FireServer("sdarkblade","UnEquipped")
	Equipped = false
end)

and thx

Instead of using UserInputService you should use Tool.Activated

does it will work ? or not on mobile

i try do that and the tool not work for the pc and mobile

https://developer.roblox.com/en-us/api-reference/event/Tool/Activated
The ‘Activated’ event/signal of tool instances supports all device types.

1 Like