Hello Developers!
I’m having trouble with a cutlass weapon, more specifically, it’s cosmetic ability when killing an enemy. Whenever the cutlass gets a kill, it will turn bloody (Which in “Bloody”, I mean a decal of blood plastered on to it) and cause the wielder to say a random line. The only issue is that the Humanoid.Died() keeps firing for 5 times then once. I’ve tried everything to debounces and the hacky
local A
A = Humanoid.Died:Connect(function()
A:Disconnect()
end)
Command. (Yeah, I know, it was unnecessary, but still.) This is the server-script of the cutlass:
local Cutlass = script.Parent
local ATKEvent = Cutlass:WaitForChild("ATKFireEvent")
local OnKillMessages = {
"Bloody 'ell! ye've gotten me cutlass all bloody! but that there doesn't matter though, because yer dead.",
"Told yarr not to mess with me.",
"Fight like a man next time. Although, yer already dead me mate.",
"See ye in 'ell!",
"Me blade ain't a match towards yarr fancy weaponary.",
"Too fast fer ye? Too bad.",
"Harharr! Ooooh harharr!",
"Demoknight, demoknightin? Avast speakin' nonsense, yer not even makin' sense.",
"Too fast fer yarr bullets?",
"Maybe if ye where aware that there I can dash, maybe ye would've gotten me!",
"Harharr! Look at ye! Ye look like a fool to me! Harharr!",
"I'll see yarr in 'ell, bilge rat. An' ye better clean me blade fer me whenever I spy ye again.",
"Jolly, yer organs be stuck to me blade. Maybe even yer worthless bones scratched it.. Or maybe even broke it.",
"Get off me blade, get off, get off!",
"I should've make me blade not sticky enough fer peasants such as yerself to stick to a more valuable cutlass then yarr.",
"Picked the wrong person to fight with!",
"This here isn't gettin' fun anymore, it be too easy fer me now.",
"Ye know, why even bother fightin' me matey? Like, seriously, why? Ye can't even 'it me in like, five 'its. Maybe I forgotten but I don't give a damn to the depths really. Go take yer weak body somewhere ye can actually win, the graveyard.",
"I've actually gotten a secret fer ye before I smell yarr stinky breath, the secret ye might ask? I got a god-damn cutlass fer the love o' god!",
"Try again! IN 'ELL!",
}
ATKEvent.OnServerEvent:Connect(function(Plr,ATKType)
if ATKType == "LMB" then
local SwingAnim = Plr.Character.Humanoid:WaitForChild("Animator"):LoadAnimation(Cutlass.Dash)
SwingAnim:Play()
task.wait(0.10)
local CanHit = true
Cutlass.Handle:FindFirstChild("Swing"):Play()
Cutlass.Handle.Touched:Connect(function(OnHit)
local Character = OnHit:FindFirstAncestorWhichIsA("Model")
local Humanoid = Character and Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid and CanHit == true then
CanHit = false
Cutlass.Handle.Stab:Play()
Humanoid:TakeDamage(22)
local Connection
local function onHumanoidDeath()
Cutlass.Handle.Blood.Transparency = 0
game:GetService("Chat"):Chat(Plr.Character.Head,OnKillMessages[math.random(1, #OnKillMessages)],Enum.ChatColor.White)
Connection:Disconnect()
end
Connection = Humanoid.Died:Connect(onHumanoidDeath)
end
end)
local LinearVelocity = Instance.new("LinearVelocity",Plr.Character.PrimaryPart)
local Attachment = Instance.new("Attachment",Plr.Character.PrimaryPart)
LinearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
LinearVelocity.PrimaryTangentAxis = Vector3.new(1, 0, 0)
LinearVelocity.SecondaryTangentAxis = Vector3.new(0, 0, 1)
LinearVelocity.MaxForce = math.huge
LinearVelocity.Attachment0 = Attachment
LinearVelocity.VectorVelocity = Plr.Character.PrimaryPart.CFrame.LookVector * 80
game:GetService("Debris"):AddItem(LinearVelocity,0.5)
game:GetService("Debris"):AddItem(Attachment,0.5)
end
end)