Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't a point being added to the leader board?

So as i had previously asked, my code won't give me one kill per kill. I get more then one kill. So I added a debouce system. Now, instead of getting any points, i get none. Why does that happen? Here is my script.

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

1 comment

2 answers

In this instance do not use connection:Disconnect because it stops the function.

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)
    else
        damage = damage / 2
        if damage < 2 then
            ball.Parent = nil
        end
    end

don't use connection:Disconnect() on this situation, if it dont have lines it doesnt run anything, connection:Disconnect() only stops the function and it's unable to get listened, basically disable the function

Heres a very cool explanation by roblox:

Always call Disconnect() when a connection is no longer needed. Forgetting to do so can cause your game to use more resources than necessary. Note, however, that this may not always be necessary; when an object is destroyed, all connections to that object’s events are disconnected automatically.

36 comments

0

So in other words, this kinda feels like the disconnect isn't whats wrong, the way roblox explained it. Remember, im not getting any points even if i died 500 times

0

your answer doesn't work. Please check again

0

Wat

0

it doesnt work

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

it doesnt work lol

0

WHAT THE HELL 31 NOTIFCATIONS I GONNA DIN YOU

This discussion is preserved as it was. New answers, comments, and votes are closed.