-- Services
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ClonedHurtbox = game.ReplicatedStorage.SmallHurtbox:Clone()
game:GetService('RunService').Stepped:Wait()
-- Variables
local sword = script.Parent
local Player = script.Parent.Parent.Parent
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
local Animator: Animator = Humanoid:WaitForChild("Animator")
local Debounce = {}
local COOLDOWN_DURATION = 1.30
-- Animations
-- Animation Stuff
local function CreateAnimationTrack(ID)
local AnimFile = Instance.new("Animation")
AnimFile.AnimationId = ID
local AnimTrack = Animator:LoadAnimation(AnimFile)
return AnimTrack
end
local SwordIdle = CreateAnimationTrack("rbxassetid://14850115859")
local SwordSwing1 = CreateAnimationTrack("rbxassetid://14850117022")
local SwordSwing2 = CreateAnimationTrack("rbxassetid://14850118030")
local SwordSwing3 = CreateAnimationTrack("rbxassetid://14850119287")
local CrouchEntry = CreateAnimationTrack("rbxassetid://14776702318")
local CrouchExit = CreateAnimationTrack("rbxassetid://14776704918")
local ProneCrawl = CreateAnimationTrack("rbxassetid://14777151648")
local ProneIdle = CreateAnimationTrack("rbxassetid://14777127384")
local SprintAnim = CreateAnimationTrack("rbxassetid://14827395801")
local ClimbAnim = CreateAnimationTrack(("rbxassetid://14827395801"))
local function Play(Track: AnimationTrack)
if not Track.IsPlaying then Track:Play() end
end
local function Stop(Track: AnimationTrack)
if Track.IsPlaying then Track:Stop() end
end
if Humanoid.MoveDirection.Magnitude < 1 then
for _, idk in {ProneIdle, ProneCrawl, CrouchExit, CrouchEntry, ClimbAnim} do
if idk.IsPlaying then
return
end
end
Play(SwordIdle)
else
Stop(SwordIdle)
end
sword.Activated:Connect(function()
for _, idk in {ProneIdle, ProneCrawl, CrouchExit, CrouchEntry, ClimbAnim, SprintAnim} do
if idk.IsPlaying then
return
end
end
function Swing()
local AnimationChosen = math.random(1,3)
if AnimationChosen == 1 then
Play(SwordSwing1)
elseif AnimationChosen == 2 then
Play(SwordSwing2)
elseif AnimationChosen == 3 then
Play(SwordSwing3)
end
ClonedHurtbox:Clone()
ClonedHurtbox.Parent = Player
end
end)
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Swing()
end
end)
need it to place a hitbox infront of the player when you swing but it wont
also cant get it to have a cooldown, or not play when other animations are playing