You can use a quick debug test here. Rebind it to right click just for now. Then test your tool if it works on PC then you know it is that line of code causing it. Since mobile cannot click i assume thats why the tool works there and not on PC. Test this out and get back to me!
It is not bugged. It is because you are removing roblox’s core handler. Example you are overwriting the camera now. So the camera handler is no longer a thing. Since it is binded to attack. But does the tool work?
I recommend dropping the use of Context Action Service and rewriting your script to rely on UserInputService, here you will be able to detect when the player is Left Clicking. It will not override any of roblox’s functionality.
You can create your own mobile buttons i believe. I would suggest looking into that. All you would have to do is check when the UIS.InputChanged is connected. if it is mobile then parent a screenGui to the player. if it is not do nothing.
Here is a link what i referenced above… If you are lazy then dont add mobile support. There is not much i can do besides saying reroute your Keybind to a Key on the keyboard. I do believe this community tutorial will help you as it supplies a lot, i did a quick run through of it and it looks pretty good! Take the opportunity to make this a learning experience for you! Mobile players are one of the core parts of Roblox games.
I wish you the best of luck! You dont have to go all out. Just get a simple little prototype working even an image/ text button will do! Then later you can always adjust pre-launch.
Unless you do what @uriel_Gamer444 said above. You will have to just make a simple text button then parent it to mobile. It is really easy to do. Shouldnt take more than 5 minutes. Then just check when the button is clicked then run the function of your Attack.
If do not want mobile players in your game then yes. But remember your tools wont work unless you switch to UserInputService. There is a more advance way of going about your Context Action Service without using tools. You would have to make your own HUD, store it to the player so you can reference it. And when the player attacks you can check which attack it is by seeing what you stored. But considering you do not wanna go through the struggle of adding your own buttons for mobile. I dont think itll be something you would take on
Check if player is on mobile using UIS.InputChanged. If they are on input.UserInputType == Enum.UserInputType.Touch then you just Clone your screengui of buttons and parent it to the player in player gui. Store this local script in StarterPlayerScripts.
ContextActionService is really good, just have to know how to work with it
A possibility is Unbinding Attack for the tools function on equip and rebinding Attack on unequip
local ContextActionService=gamer:GetService("ContextActionService")
local Tool=script.Parent
local drinkFunction()
--Code that i don't wanna copypaste
end
Tool.Equipped:Connect(function()
ContextActionService:Unbind("Attack")
ContextActionService:BindAction("Drink", drinkFunction, false, Enum.UserInputType.MouseButton1)
end)
Tool.Unequipped:Connect(function()
ContextActionService:Unbind("Drink")
ContextActionService:BindAction("Attack", handleAttack, false, Enum.UserInputType.MouseButton1)
--Create button to false cause you should still do custom buttons lol
end)