I’m trying to figure out how to make a sword play another animation if m1/left click is pressed again, and again. Essentially a combo.
This is the code I’m working with. I’m using swordphin’s public raycast module to help with it.
local userInputService = game:GetService("UserInputService")
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local characterPlayer = player.Character or player.CharacterAdded:Wait()
local humanoidPlayer = characterPlayer:WaitForChild("Humanoid")
local replicatedStorage = game.ReplicatedStorage
local raycastModule = require(replicatedStorage.RaycastHitboxV4)
local hitBox = raycastModule.new(tool)
--local newHitbox = raycastModule.new(script.Parent.Hitbox)
hitBox:SetPoints(tool.Handle, {Vector3.new(1, 0, 0), Vector3.new(5, 0, 0), Vector3.new(10, 0, 0)})
--newHitbox:SetPoints(script.Parent, {Vector3.new(0, 3, 0), Vector3.new(-5, 3, 0), Vector3.new(5, 3, 0)})
local RaycastParams = RaycastParams.new()
RaycastParams.FilterDescendantsInstances = {characterPlayer}
RaycastParams.FilterType = Enum.RaycastFilterType.Exclude
hitBox.RaycastParams = RaycastParams
function OnTouch(hit, humanoid)
print(hit.Name)
humanoid:TakeDamage(25)
end
function OnActivation()
hitBox:HitStart() --- Starts the hit detection
wait(10) --- Wait a few seconds
hitBox:HitStop() --- Stops the hit detection
end
hitBox.OnHit:Connect(OnTouch)
tool.Activated:Connect(OnActivation)
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://15161132977"
local track
local function onInputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
track = characterPlayer.Humanoid.Animator:LoadAnimation(animation)
track.Priority = Enum.AnimationPriority.Action4
track.Looped = false
track:Play()
wait(10)
track:Stop()
end
end
userInputService.InputBegan:Connect(onInputBegan)
--userInputService.InputEnded:Connect(function(input, gameProcessed)
-- if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- wait(2)
-- track:Stop()
-- end
--end)
I’m a beginner so this might not be the best first project I should be doing.