Hey guys! Im currenlty working a melee system and you can hold on your mouse to draw back the bayonet.
Once you release it swings forward, this part works fine, but im trying to make it so if you just click it will also just do a small swing forward. How can I go about this. I tried doing it and it bugs out like this.
Here’s a video of the holding back on bayonet:
https://i.gyazo.com/2a7652d1d6aff1916cf45b5f457ad05b.mp4
Here’s a video of me just clicking once,
https://i.gyazo.com/db0cb62853f8e3c9f0d2f5943e20c2cd.mp4
The animation bugs out and just paused, this could be due to the animationhandaler module but ill drop the code anyways.
MODULE:
function Musket.DownSwingPrepare()
downSwing:Play()
wait(0.25)
downSwing:AdjustSpeed(0)
end
function Musket.DownSwing()
downSwing:AdjustSpeed(1)
wait(0.75)
downSwing:Stop()
end
Client:
UserInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
if equpied == true and bayonetMode == true and cooling == false then
local direction = MouseDirection.get(MouseDirection.Direction.Down, MouseDirection.Direction.Up)
if direction == MouseDirection.Direction.Up then
print("DRAWN_TOP")
cooling = true
held = true
elseif direction == MouseDirection.Direction.Down then
print("DRAWN_BUTTOM")
cooling = true
held = true
animationHandler.DownSwingPrepare()
end
while held do
print("DRAWN_BACK")
wait()
end
end
end
end)
UserInputService.InputEnded:Connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
if equpied == true and bayonetMode == true and cooling == true then
local direction = MouseDirection.get(MouseDirection.Direction.Down, MouseDirection.Direction.Up)
if direction == MouseDirection.Direction.Up then
elseif direction == MouseDirection.Direction.Down then
print("s")
cooling = false
held = false
animationHandler.DownSwing()
end
end
end
end)
Any help loved!