As you can probably guess from the title, the following script should reward the owner of the knife 1 kill and 15 Cash. Instead, it gives 2 kills and 30 Cash. I cannot find the problem though. Please help?
This is the function I suspect that has the issue in it: This chunk is around 60 lines long
function BlowDamage(hit, damage)
local humanoid = hit.Parent:FindFirstChild('Humanoid')
local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
if humanoid == nil then
Handle.WallHit:Play()
wait(0.1)
a = game.Workspace:FindFirstChild("Handle")
if a == nil then
else
a:Destroy()
end
else
if humanoid.Health == 0 then
game.Players.LocalPlayer.leaderstats.Kills.Value = game.Players.LocalPlayer.leaderstats.Kills.Value + 1
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 15
Handle.DeadPlayer:Play()
Handle.DeadSound:Play()
else
humanoid.Health = humanoid.Health - THROWING_DAMAGE
if humanoid.Health <= 0 then
game.Players.LocalPlayer.leaderstats.Kills.Value = game.Players.LocalPlayer.leaderstats.Kills.Value + 1
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 15
Handle.DeadPlayer:Play()
Handle.DeadSound:Play()
end
end
wait(0.1)
if a == nil then
else
a:Destroy()
end
end
if humanoid ~= nil and MyHumanoid ~= nil and humanoid ~= MyHumanoid then
if not MyPlayer.Neutral then
-- Ignore teammates hit
if player and player ~= MyPlayer then
return
end
end
-- final check, make sure weapon is in-hand
local rightArm = MyCharacter:FindFirstChild('Right Arm')
if (rightArm ~= nil) then
-- Check if the weld exists between the hand and the weapon
local joint = rightArm:FindFirstChild('RightGrip')
if (joint ~= nil and (joint.Part0 == Handle or joint.Part1 == Handle)) then
-- Make sure you only hit them once per swing
if player and not HitPlayers[player] then
TagHumanoid(humanoid, MyPlayer)
print("Sending " .. damage)
humanoid:TakeDamage(damage)
Handle.Splat.Volume = 1
Handle.Splat:Play()
HitPlayers[player] = true
end
end
end
end
end
If that's not the problem, here's the link to the full knife script: WARNING!! ITS AROUND 300 LINES LONG Knife Script

3 comments
How do I merge 2 ifs together... And which lines do you recommend to be removed?
I edited it to explain. Does that help?
Very little though. I'm still not 100% sure