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

Debounce Brick won't work?

I want to make it so when a Player hits a brick, it gives them 1 Player Point, not 8... Anyways, here's the script.

local buttonPressed = false

local How_Much_To_Award = 1 -- How much Player Points to award.
script.Parent.Touched:connect(function(plr)
	if not buttonPressed then
		buttonPressed = true
	end
	wait()
	local i = plr.Parent.Name
	if plr.Parent:findFirstChild("Humanoid") then
	print(plr.Parent.Name)
	game:GetService("PointsService"):AwardPoints(game.Players:findFirstChild(i).userId, How_Much_To_Award)
	buttonPressed = false
	print("Done.")
	end
end)

1 answer

✓ Accepted answer

You don't actually have anything to keep it from running if buttonPressed is true

local buttonPressed = false

local How_Much_To_Award = 1 -- How much Player Points to award.
script.Parent.Touched:connect(function(plr)
    if buttonPressed == true then return end -- Causes the function to end here if buttonPressed is true
    buttonPressed = true
    wait()
    local i = plr.Parent.Name
    if plr.Parent:findFirstChild("Humanoid") then
    print(plr.Parent.Name)
    game:GetService("PointsService"):AwardPoints(game.Players:findFirstChild(i).userId, How_Much_To_Award)
    buttonPressed = false
    print("Done.")
    end
end)

2 comments

0

It sorta slowed it down, but it still gives a lot away, is there a way to fix this?

0

Nevermind, I got it, thank's

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