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

Why does a player get points even though the cannon ball won't touch anything?

Asked by
Xyternal 247 Moderation Voter
2 years ago
Edited 2 years ago

So following my pervious question, after an answer, i got a code, but for some reason when ever the cannon fires, and even though it doesnt hit a player, it still gives me pointss. Why does that happen? code

ball = script.Parent
damage = 50
local debounce = true
function onTouched(hit)


    local humanoid = hit.Parent:findFirstChild("Humanoid")
    if humanoid~=nil then
        tagHumanoid(humanoid)
        humanoid.Health = humanoid.Health - damage
    if debounce then
debounce = false
        if humanoid.Health == 0 or humanoid.Health < 0 then
            local z = game.Players:FindFirstChild(game.ReplicatedStorage.asd.Value)
            z.leaderstats.Kills.Value += 1
        wait(2)
debounce = true
        end
end

        untagHumanoid(humanoid)

        connection:disconnect()
    else
        damage = damage / 2
        if damage < 2 then
            connection:disconnect()
            ball.Parent = nil

        end
    end

EDIT: I've learned how to fix that problem, but is there any way I can add a debounce, because my cannon fires multiple cannon balls, so i want it that the player shouldn't get two points even if more than two cannon balls hit it.

0
I've tried doing the traditional debounce, but it doesn't work Xyternal 247 — 2y

Answer this question