How to make this blood system work for a melee?

I want to make these lines of code work for a melee system. Basically, the blood system works for a gun system (RRP2 heavily edited by me), but I want to make it also work for a melee system. Both systems use different values, and I don’t know how to make it work.

Gun Bleed Script:
script.Parent.DamageEvent.OnServerEvent:Connect(function(plr,Target)
local animation = Target:LoadAnimation(anim)
animation:Play()
local Damage = script.Parent.Damage.Value
Target.Health = Target.Health - Damage
local blood1 = game.ReplicatedStorage.Blood1:Clone()
local blood2 = game.ReplicatedStorage.Blood2:Clone()
blood1.Parent = Target.Parent.UpperTorso
blood2.Parent = Target.Parent.UpperTorso

wait(1)
blood1.Rate = 10
blood2.Rate = 10
wait(0.1)
	blood1.Rate = 6
blood2.Rate = 6
wait(0.1)
	blood1.Rate = 4
blood2.Rate = 4
wait(0.1)
	blood1.Rate = 2
blood2.Rate = 2
wait(0.2)
	blood1.Rate = 1
blood2.Rate = 1
wait(0.1)
	blood1.Rate = 0
blood2.Rate = 0
wait(1)
	blood1:Destroy()
blood2:Destroy()

end)


Melee Sword Script:
parent.Activated:Connect(function()
if Handle.Transparency == 1 then return end
function slash()
print(“hip”)
local creator = Creator.Value
local Animations = parent:WaitForChild(“Animations”)
local AnimChild = Animations:GetChildren()
local AnimRad = math.random(1,#AnimChild)
local AnimSel = AnimChild[AnimRad]
local AP = creator:WaitForChild(“Humanoid”):LoadAnimation(AnimSel)
if Can == true then
Can = false
AP:Play()
wait(0.15)
CanDmg = true
Handle.Swing:Play()
Handle.SlashTrail.Enabled = true
wait(0.25)
CanDmg = false
Handle.SlashTrail.Enabled = false
wait(0.06)
Can = true
end
end
slash()
end)
function on(t)
local h = t.Parent:FindFirstChildOfClass(“Humanoid”)
if h ~= nil and CanDmg == true then
CanDmg = false
local cre = Creator.Value
h:TakeDamage(parent.Dmg.Value)
Handle.Swing:Stop()
Handle.Hit:Play()
if h.Health>0 then
if not h:FindFirstChild(“creator”) then
local ov = Instance.new(“ObjectValue”,h)
ov.Name = “creator”
ov.Value = game.Players:WaitForChild(cre.Name)
else
local ovs = h:GetChildren()
for i = 1,#ovs do
if (ovs[i].Name == “creator”) then
ovs[i].Value = game.Players:WaitForChild(cre.Name) end
end
end
end
end
end
Handle.Touched:Connect(on)

1 Like