Since I am rewriting this from the ground up for a better version, I thought I would open source the old version. This version doesnt include everything I aimed to include
Beware of jankiness with swimming
Unsure what this game is about, since you haven’t specified. But, there’s a bug:
If you click, your tool is activated. When you let go of your mouse, it is activated again. Are you using ContextActionService incorrectly? Did you forget to check if the state is Begin?
(edit): Yes! You need to check if the state is Begin, or else you will swing for any state.
Another bug which this code has that I didn’t see at first: All mouse button 1 inputs sink here inappropriately, since it only swings when that if statement is true.
The fixed code is as follows:
ContextActionService:BindAction("action1", function(_, state: Enum.UserInputState, input: InputObject)
if state == Enum.UserInputState.Begin and p.character and deathMessage == "" and math.abs(a-tick()) > 0.15 then
a = tick()
swing:Play()
action1:FireServer(CurrentItem,mouse.Hit.Position, mouse.Target,camera.CFrame)
return Enum.ContextActionResult.Sink
end
return Enum.ContextActionResult.Pass
end, true, Enum.UserInputType.MouseButton1)
ContextActionService:BindAction("action2", function(_, state: Enum.UserInputState, input: InputObject)
if state == Enum.UserInputState.Begin and p.character and deathMessage == "" and math.abs(a-tick()) > 0.15 then
a = tick()
action2:FireServer(items[CurrentItem],mouse.Hit.Position, mouse.Target)
return Enum.ContextActionResult.Sink
end
return Enum.ContextActionResult.Pass
end, true, Enum.UserInputType.MouseButton2)