Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local replicatedStorage = game.ReplicatedStorage
- local serverStorage = game.ServerStorage
- local models = serverStorage.Assets.Models
- local animationFolder = serverStorage.Assets.Animations
- local weapons = game.ServerStorage.Assets.Weapons
- local combatAnimations = {animationFolder.RightPunch, animationFolder.LeftPunch, animationFolder.LeftKick, animationFolder.RightKick}
- local swordCombatAnimations = {animationFolder.SwordSlash}
- local contentProvider = game:GetService("ContentProvider")
- local animationsToPreload = {animationFolder.RightPunch, animationFolder.LeftPunch, animationFolder.LeftKick, animationFolder.RightKick,
- animationFolder.SwordSlash}
- contentProvider:PreloadAsync(animationsToPreload)
- local combatHandler = {}
- combatHandler.combatEvent = function(plr, combatAnimNum)
- local char = plr.Character or plr.CharaterAdded:Wait()
- local human = char:FindFirstChild("Humanoid")
- if human == nil then return end
- local hitDebounce = false
- local anim = combatAnimations[combatAnimNum]
- local animTrack = human:LoadAnimation(anim)
- local hitbox = serverStorage.Assets.Hitboxes.ArmHitbox:Clone()
- if combatAnimNum == 1 then
- hitbox.CFrame = char:WaitForChild("RightLowerArm").CFrame
- hitbox.Name = "ArmHitbox"
- local w = Instance.new("Weld", hitbox)
- w.Part0 = hitbox
- w.Part1 = char.RightLowerArm
- elseif combatAnimNum == 2 then
- hitbox.CFrame = char:WaitForChild("LeftLowerArm").CFrame
- hitbox.Name = "ArmHitbox"
- local w = Instance.new("Weld", hitbox)
- w.Part0 = hitbox
- w.Part1 = char.LeftLowerArm
- elseif combatAnimNum == 3 then
- hitbox.CFrame = char:WaitForChild("LeftLowerLeg").CFrame
- hitbox.Name = "LegHitbox"
- local w = Instance.new("Weld", hitbox)
- w.Part0 = hitbox
- w.Part1 = char.LeftLowerLeg
- elseif combatAnimNum == 4 then
- hitbox.CFrame = char:WaitForChild("RightLowerLeg").CFrame
- hitbox.Name = "LegHitbox"
- local w = Instance.new("Weld", hitbox)
- w.Part0 = hitbox
- w.Part1 = char.RightLowerLeg
- end
- hitbox.Parent = char
- spawn(function()
- wait(1)
- if char:FindFirstChild("ArmHitbox") or char:FindFirstChild("LegHitbox") then
- print("Removed")
- hitbox:Remove()
- end
- end)
- animTrack:Play()
- return hitbox
- end
- combatHandler.swordDrawEvent = function(plr)
- local char = plr.Character or plr.CharaterAdded:Wait()
- local human = char:FindFirstChild("Humanoid")
- if human == nil then return end
- local dataModule = require(game.ServerScriptService.CoreSystems.DATASTORE.DATA)
- local data = dataModule.DATA[plr]
- if data == nil then return end
- local equippedWeapon = data.Equipped
- local equippedType = char.Equipped
- if equippedWeapon and equippedWeapon ~= "None" then
- print(equippedWeapon)
- local weapon = weapons:FindFirstChild(equippedWeapon):Clone()
- if weapon == nil then return end
- print("Weapon Found!")
- weapon.Name = "Sword"
- local w = Instance.new("Weld", weapon)
- w.Part0 = weapon.Handle
- w.Part1 = char.RightHand
- w.C0 = CFrame.new(0,0,0) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))
- equippedType.Value = "Sword"
- local swordType = weapon.Settings.Type.Value
- print(swordType)
- if swordType == "Rapier" then
- --Anim Play Here
- print(1)
- wait(0.5)
- weapon.Parent = char
- elseif swordType == "Dagger" then
- --Anim Play Here
- wait(0.5)
- weapon.Parent = char
- elseif swordType == "OneHand" then
- --Anim Play Here
- wait(0.5)
- weapon.Parent = char
- elseif swordType == "TwoHand" then
- --Anim Play Here
- wait(0.5)
- weapon.Parent = char
- end
- end
- end
- combatHandler.swordSheathEvent = function(plr)
- local char = plr.Character or plr.CharaterAdded:Wait()
- local human = char:FindFirstChild("Humanoid")
- if human == nil then return end
- local dataModule = require(game.ServerScriptService.CoreSystems.DATASTORE.DATA)
- local data = dataModule.DATA[plr]
- if data == nil then return end
- local equippedWeapon = data.Equipped
- local equippedType = char.Equipped
- if equippedWeapon and equippedWeapon ~= "None" then
- local weapon = char:FindFirstChild("Sword")
- if weapon then
- local swordType = weapon.Settings.Type.Value
- if swordType == "Rapier" then
- --Anim Play Here
- wait(0.5)
- weapon:Remove()
- elseif swordType == "Dagger" then
- --Anim Play Here
- wait(0.5)
- weapon:Remove()
- elseif swordType == "OneHand" then
- --Anim Play Here
- wait(0.5)
- weapon:Remove()
- elseif swordType == "TwoHand" then
- --Anim Play Here
- wait(0.5)
- weapon:Remove()
- end
- end
- end
- end
- combatHandler.swordCombatEvent = function(plr, combatAnimNum)
- local char = plr.Character or plr.CharaterAdded:Wait()
- local human = char:FindFirstChild("Humanoid")
- if human == nil then return end
- local sword = char:FindFirstChild("Sword")
- if sword == nil then return end
- local swordType = sword.Settings.Type.Value
- print(swordType)
- local hitbox
- if swordType == "Rapier" then
- hitbox = combatHandler.rapierCombatEvent(plr, combatAnimNum)
- end
- return hitbox
- end
- combatHandler.rapierCombatEvent = function(plr, combatAnimNum)
- local char = plr.Character or plr.CharaterAdded:Wait()
- local human = char:FindFirstChild("Humanoid")
- if human == nil then return end
- local hitDebounce = false
- print("Test")
- return "Test"
- end
- combatHandler.damageCombatEvent = function(plr, hitChar, dmg)
- if hitChar:FindFirstChild("Humanoid") then
- local hitHuman = hitChar.Humanoid
- hitHuman:TakeDamage(dmg)
- end
- end
- return combatHandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement