Here is the code:
--Esentials
local tool = script.Parent
repeat wait() until tool.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local animator = tool.Parent:FindFirstChild("Humanoid").Animator
local dmgM = player.PlayerGui.Stats.DamageMultiplier.DMGmultiplier.Value
local dmgMT = player.PlayerGui.Stats.DamageMultiplier
--Animations
local animFol = tool.Animations
local holdFol = animFol.Holds
local swingFol = animFol.Swings
local prepFol = animFol.Prepares
local hold1 = animator:LoadAnimation(holdFol.Hold)
local hold2 = animator:LoadAnimation(holdFol.Hold2)
local swing1 = animator:LoadAnimation(swingFol.Swing)
local swing2 = animator:LoadAnimation(swingFol.CritSwing)
local prep1 = animator:LoadAnimation(prepFol.Prepare)
local prep2 = animator:LoadAnimation(prepFol.Prepare2)
local idle = animator:LoadAnimation(prepFol.Idle)
--Variables
local equipped = false
local holding = false
local combo = 0
local baseDMG = 25
--Code
tool.Equipped:Connect(function()
equipped = true
idle:Play()
end)
tool.Unequipped:Connect(function()
equipped = false
hold1:Stop()
hold2:Stop()
swing1:Stop()
swing2:Stop()
prep1:Stop()
prep2:Stop()
idle:Stop()
end)
tool.Activated:Connect(function()
holding = true
if combo == 0 then
idle:Stop()
hold1:Play()
dmgMT.Visible = true
repeat
dmgM += 0.01
dmgMT.Text = "x"..math.clamp(dmgM, 1, 2)
wait(0.01)
until holding == false or dmgM == 2
elseif combo == 1 then
idle:Stop()
hold2:Play()
dmgMT.Visible = true
repeat
dmgM += 0.01
dmgMT.Text = "x"..math.clamp(dmgM, 1, 2)
wait(0.01)
until holding == false or dmgM == 2
end
end)
tool.Deactivated:Connect(function()
holding = false
hold1:Stop()
hold2:Stop()
if combo == 0 and holding == false then
dmgMT.Visible = false
dmgM = 1
hold1:Stop()
swing1:Play()
tool.Handle.SwingTrail.Enabled = true
tool.Enabled = false
tool.Hitbox.CanTouch = true
tool.Handle.Swing:Play()
wait(0.3)
idle:Play()
tool.Enabled = true
tool.Hitbox.CanTouch = false
tool.Handle.SwingTrail.Enabled = false
combo += 1
elseif combo == 1 and holding == false then
dmgMT.Visible = false
dmgM = 1
hold2:Stop()
swing2:Play()
tool.Handle.SwingTrail.Enabled = true
tool.Handle.SwingTrail.Color = ColorSequence.new(Color3.fromRGB(85, 0, 0))
tool.Enabled = false
tool.Hitbox.CanTouch = true
wait(0.4)
tool.Handle.Swing:Play()
wait(0.5)
idle:Play()
tool.Enabled = true
tool.Hitbox.CanTouch = false
tool.Handle.SwingTrail.Enabled = false
tool.Handle.SwingTrail.Color = ColorSequence.new(Color3.fromRGB(255, 255, 255))
combo = 0
end
end)
tool.Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local tgrPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
if not tgrPlayer then
local hum = hit.Parent:FindFirstChild("Humanoid")
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
humRP.AssemblyLinearVelocity = Vector3.new(50, 25, 0)
tool.Handle.Hit:Play()
local total = baseDMG * dmgM
hum:TakeDamage(total)
print(total)
tool.Hitbox.CanTouch = false
elseif tgrPlayer then
return end
end
end)
I tried making it where when the player charges the tool up for a specific amount of time, the damage output will be multiplied to the base damage.
For example: When I charge the tool until it hits the maximum, the base damage will be multiplied by the damage multiplier.
I tried doing “Humanoid:TakeDamage(total)” as you can see in the piece of code and tried printing the damage output. It was only printing the base damage, and not the total damage. How do I fix this?