local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local BasicCombat = script.Parent
local player = game.Players.LocalPlayer
local M1 = ReplicatedStorage.RemoteEvents.Combat.M1
local M1Stop = ReplicatedStorage.RemoteEvents.Combat.M1Stop
local M1Animations = {
[1] = ReplicatedStorage.Animations.Styles.Basic.M1Anim1,
[2] = ReplicatedStorage.Animations.Styles.Basic.M1Anim2,
[3] = ReplicatedStorage.Animations.Styles.Basic.M1Anim3,
[4] = ReplicatedStorage.Animations.Styles.Basic.M1Anim4,
[5] = ReplicatedStorage.Animations.Styles.Basic.M1Anim5,
[6] = ReplicatedStorage.Animations.Styles.Basic.M1Anim6,
}
local blocking = false
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
blocking = true
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
blocking = false
end
end)
local function hit (player,AnimationPlaying)
player.Character.Humanoid.WalkSpeed = 14
M1:FireServer(AnimationPlaying)
end
local function endhit (player,AnimationPlaying)
player.Character.Humanoid.WalkSpeed = 16
M1Stop:FireServer(AnimationPlaying)
end
local equipped = false
BasicCombat.Equipped:Connect(function()
local Idleanim = ReplicatedStorage.Animations.Styles.Basic.Idle -- make seperate tool for every style
local Idleanimtrack = player.Character.Humanoid:LoadAnimation(Idleanim)
local Walkanim = ReplicatedStorage.Animations.WalkLegsOnly
local Walkanimtrack = player.Character.Humanoid:LoadAnimation(Walkanim)
local AnimationPlaying = false
equipped = true
Idleanimtrack:Play()
UserInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local number = math.random(1,6)
local M1AnimTrack1 = player.Character.Humanoid:LoadAnimation(M1Animations[1])
local M1AnimTrack2 = player.Character.Humanoid:LoadAnimation(M1Animations[2])
local M1AnimTrack3 = player.Character.Humanoid:LoadAnimation(M1Animations[3])
local M1AnimTrack4 = player.Character.Humanoid:LoadAnimation(M1Animations[4])
local M1AnimTrack5 = player.Character.Humanoid:LoadAnimation(M1Animations[5])
local M1AnimTrack6 = player.Character.Humanoid:LoadAnimation(M1Animations[6])
if equipped == true then
if blocking == false then
if number == 1 then
if AnimationPlaying == false then
M1AnimTrack1:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack1.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
elseif number == 2 then
if AnimationPlaying == false then
M1AnimTrack2:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack2.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
elseif number == 3 then
if AnimationPlaying == false then
M1AnimTrack3:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack3.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
elseif number == 4 then
if AnimationPlaying == false then
M1AnimTrack4:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack4.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
elseif number == 5 then
if AnimationPlaying == false then
M1AnimTrack5:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack5.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
elseif number == 6 then
if AnimationPlaying == false then
M1AnimTrack5:Play(0.1,1,1.35)
AnimationPlaying = true
hit(player,AnimationPlaying)
M1AnimTrack6.Stopped:Wait()
AnimationPlaying = false
endhit(player,AnimationPlaying)
end
end
end
end
end
end)
player.Character.Humanoid.Running:Connect(function(speed)
if speed > 0 then
Walkanimtrack:Play()
elseif speed == 0 then
Walkanimtrack:Stop()
end
end)
BasicCombat.Unequipped:Connect(function()
equipped = false
Idleanimtrack:Stop()
end)
end)
server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local M1 = ReplicatedStorage.RemoteEvents.Combat.M1
local M1Stop = ReplicatedStorage.RemoteEvents.Combat.M1Stop
local DestroyBlock = ReplicatedStorage.BindableEvents.DestroyBlock
local OnHitAnim = ReplicatedStorage.Animations.OnHit
local hitsound = game.Workspace.Sounds.HitSound
local hitblocked = game.Workspace.Sounds.HitBlocked
local function onhit (character,playerwhohit)
local player1hrp = character.HumanoidRootPart -- player that recives hit
local player2hrp = playerwhohit.Character.HumanoidRootPart -- player who hit
local randomknockback = math.random(8,12)
local knockback = Instance.new("BodyVelocity")
local OnHitTrack = character.Humanoid:LoadAnimation(OnHitAnim)
OnHitTrack:Play(0.1,1,2.25)
knockback.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
knockback.Velocity = Vector3.new(0,3,0) + player2hrp.CFrame.LookVector * randomknockback
knockback.Parent = player1hrp
hitsound:Play()
wait(0.25)
knockback:Destroy()
end
local function hitBlocked (character)
local player = game.Players:FindFirstChild(character.Name)
DestroyBlock:Fire(player)
end
local function Blocked (BlockPart)
BlockPart.Transparency = 0.85
hitblocked:Play()
wait(0.10)
BlockPart.Transparency = 0.7
end
local function finddamage (style)
if style == "Basic" then
return 9.5
end
end
M1.OnServerEvent:Connect(function(player,AnimationPlaying)
local fireray = Ray.new(player.Character.HumanoidRootPart.Position,player.Character.HumanoidRootPart.CFrame.LookVector * 3.60)
local human = player.Character.Humanoid
local style = player.PvPStats.Style
local Damage = finddamage(style.Value)
local commands = {
blocking = player.Character.Blocking
}
local hit,position = game.Workspace:FindPartOnRayWithIgnoreList(fireray,{script.Parent})
if hit then
if hit.Name == ("HitBox") then
if hit:IsA("Part") or hit:IsA("MeshPart") then
hit.Parent.Health = hit.Parent.Health - Damage
onhit(hit.Parent.Parent,player)
if hit.Parent.Parent:FindFirstChild("BlockPart") and hit.Parent.Parent:FindFirstChild("WeldBlock") then
hitBlocked(hit.Parent.Parent)
end
end
elseif hit.Name == ("BlockPart") then
if hit:IsA("Part") then
local blockedDamage = 0.75 * Damage
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - blockedDamage
Blocked(hit)
end
end
end
if AnimationPlaying == true then
for i,command in pairs(commands) do
command.Disabled = true
end
end
end)
M1Stop.OnServerEvent:Connect(function(player,AnimationPlaying)
local commands = {
blocking = player.Character.Blocking
}
if AnimationPlaying == false then
for i,command in pairs(commands) do
command.Disabled = false
end
end
end)