I can’t find a way to balance the sword so that it does damage because now it can do 10 damage sometimes and like 18 damage
script:
local Sword = script.Parent
local db = false
local DefaultDamage = Sword:GetAttribute("SwordDamage")
local Animations = {Sword.Slash,Sword.Slash,Sword.Slash2}
local Module = require(game.ReplicatedStorage.ClientModules.BasicFunctions)
local SH = require(game.ServerScriptService.Modules.ObjectModules.SwordHandler)
local AnimationDb = false
Module:WeldModel(Sword,Sword.Handle) -- welds model to handle
SH:SetProperties(Sword)
Sword.Equipped:Connect(function()
game:GetService("RunService").Stepped:Connect(function()
if AnimationDb == false then
AnimationDb = true
if Sword.Parent:FindFirstChild("Humanoid") then
local Humanoid = Sword.Parent:FindFirstChild("Humanoid")
Humanoid:LoadAnimation(Sword.Equip):Play()
else
AnimationDb = false
end
end
end)
end)
Sword.Unequipped:Connect(function()
AnimationDb = false
end)
Sword.Activated:Connect(function()
local char = Sword.Parent
local player = game.Players:GetPlayerFromCharacter(char)
if db == false and player.CanFight.Value == false then
local ChosenAnim = Animations[math.random(1,#Animations)]
local load = Sword.Parent:FindFirstChild("Humanoid"):LoadAnimation(ChosenAnim)
load:Play()
repeat wait() until not load.IsPlaying
db = true
if ChosenAnim == Sword.Slash2 then
Sword:SetAttribute("SwordDamage",6)
else
Sword:SetAttribute("SwordDamage",DefaultDamage)
end
wait(1)
db = false
end
end)
Sword.Cube.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= Sword.Parent and db == true then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(Sword:GetAttribute("SwordDamage"))
db = false
wait(1)
db = true
end
end)