Some help with my local script

hi i have to local script one mobile and one pc the pc work but the mobile not work can anyone know where the wrong in local script
the pc script

--|| 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("ssKatana", "Equipped")
	AnimationHandler.PlayAnim("swordequip")
	
	UserInputService.InputBegan:Connect(function(Input,Typing)
		if Typing == false and Input.UserInputType == Enum.UserInputType.MouseButton1 and Equipped then
			ServerRemote:FireServer("ssKatana", "Sword", "ssKatana")
		end
	end)
	


end)

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

the mobile script where the problem i have

local Player = game:GetService('Players').LocalPlayer
local Tool = Player.Character:FindFirstChild('katan')--put your tools name here
local DB = true -- cooldown
local using = false
local Mouse = Player:GetMouse()
local Debounce = 1
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
Tool.Equipped:Connect(function()
	Equipped = true
	ServerRemote:FireServer("ssKatana", "Equipped")
	AnimationHandler.PlayAnim("swordequip")	
script.Parent.MouseButton1Click:Connect(function()
		if Tool.Activated and Equipped then
			ServerRemote:FireServer("ssKatana", "Sword", "ssKatana")
end
end)
end)
Tool.Unequipped:Connect(function()
	ServerRemote:FireServer("ssKatana","UnEquipped")
	Equipped = false
end)

and thx

i try a lot of thing to fix but still no does anyone know why it happen all script is the same and there no alot of change

i have fix by remove tool i was add tool for that it back to work

Instead of UserInputService I recommend you look into ContextActionService.

1 Like

He should just used Tool.Activated for this overall

2 Likes

Agreed, it already supports all device types, there’s no need to re-invent the wheel.

1 Like