Hello, everyone.
I'm trying to create a punch event that doesn't require a tool to be selected, but instead, by left clicking the mouse in order to trigger the event. I've come across few tutorials that are repitive in the sense that they are all KeyCode activated with "q" or "e", however, I couldn't find or resolve my issue with using the mouse instead. Here is an example of what I am using:
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent")
local ready = true
local function punch(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.Q and ready then
punchEvent:FireServer()
ready = false
wait(0.5)
ready = true
end
end
UserInputService.InputBegan:Connect(punch)
I'm pretty sure that the KeyCode doesn't reach Mouse events. I've been doing my research throughout the Roblox Scripting Wiki. All suggestions and recommendations are welcome. Thank you, for your time.
- sparkevin

1 comment
Thank you, good sir. :D