Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Knife kills player but doesn't award cash, Why?

Asked by 9 years ago

This is part of a script that is responsible for damaging the opponents health as well as reward the player with 10 FCash, 1 Spree and 1 Counter. It kills the opponent but doesn't give me cash. Why?

local HitPlayers = {}

local LeftButtonDownTime = nil

local Attacking = false

function Blow(hit)
    if Attacking then
        BlowDamage(hit, Damage)
    end
end

function BlowDamage(hit, damage)
    local humanoid = hit.Parent:FindFirstChild('Humanoid')
    --local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
    if humanoid ~= nil and MyHumanoid ~= nil and humanoid ~= MyHumanoid then
        -- 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  not HitPlayers[hit.Parent] and humanoid.Health>0 and MyHumanoid.Health>0 then
                    TagHumanoid(humanoid, MyPlayer)
                    print("Sending " .. damage)
                    humanoid.Health=humanoid.Health-damage
                    Handle.Splat.Volume = 1
                    HitPlayers[hit.Parent] = true
                    if humanoid.Health < 0 and MyHumanoid.Health>0 then
                        local leaderstats = MyPlayer.leaderstats
                        local Counter = MyPlayer.Counter
                        local Spree = leaderstats.Spree
                        Counter.Value = Counter.Value +1
                        Spree.Value = Spree.Value +1
                        leaderstats.FCash.Value = leaderstats.FCash.Value +10
                        HitPlayers[hit.Parent] = false
                        wait(10)
                    end
                end
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by 9 years ago

At line 30, try doing if humanoid.Health <= 0 and MyHumanoid.Health > 0 then

0
Problem with that is, If I hit the dead player again after he dies, i am rewarded twice which I don't want fahmisack123 385 — 9y
0
use a debounce then? ConnorXV 5 — 9y
Ad

Answer this question