local Tool = script.Parent
local Animation = script.Parent:WaitForChild("Attack")
local AnimationId = {
Animation1 = "rbxassetid://14161281319",
Animation2 = "rbxassetid://14161288180",
Animation3 = "rbxassetid://14161290360",
Animation4 = "rbxassetid://14161292365",
Animation5 = "rbxassetid://14161301152"
}
local Debounce = true
local DamageRarity = {
{5,70},
{8,15},
{10,10},
{12,5},
}
function DamageChance()
if DamageRarity then
local types = {}
local prng = Random.new()
for a,b in ipairs(DamageRarity) do
local r = b[2]
for t=1,r*100 do
table.insert(types,b[1])
end
end
return types[prng:NextInteger(1,#types)]
end
return 0
end
function Attack(Player, Enemy)
local Humanoid = Tool.Parent:WaitForChild("Humanoid")
local Damage = DamageChance()
Enemy.Humanoid.Health -= Damage
print(Damage)
local FightUtils = require(game:GetService("ServerScriptService").player:WaitForChild("FightUtils"))
FightUtils.Knockback(Player, Enemy)
Tool.Handle.PunchSound:Play()
end
Tool.Activated:Connect(function()
if Debounce == true then
Debounce = false
Animation.AnimationId = AnimationId["Animation"..math.random(1,5)]
Tool.Parent.Humanoid:LoadAnimation(AnimationId):Play()
script.Swing:Play()
Tool.Handle.Trail.Enabled = true
Tool.Parent.Humanoid.WalkSpeed = 3
Tool.Parent.Humanoid.JumpPower = 0
for _, Enemy in pairs(game:GetService("Workspace").Enemies:GetChildren()) do
if (Tool.Handle.Position - Enemy.HumanoidRootPart.Position).Magnitude <= 5 then
Attack(Tool.Parent, Enemy)
end
end
task.wait(0.4)
Tool.Parent.Humanoid.WalkSpeed = 7
Tool.Parent.Humanoid.JumpPower = 15
Tool.Handle.Trail.Enabled = false
Debounce = true
end
end)
No Errors pop up neither does it work.