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

GIVE JUST ONE POINTS (OnTouched) - Part ?

i need help for something. it my script (i want Exemple if someone touch the part that give one points only) INFO : WHEN I TOUCH IT, IT GIVE 160 POINTS AND I JUST ONE ONLY 1 POINT

WinPlace1 = script.Parent
WinPlace1.Touched:connect(function()
	print(game.Players.LocalPlayer)
	wait(3)
	game.Players.LocalPlayer.leaderstats.point.Value= game.Players.LocalPlayer.leaderstats.point.Value +1
end)

1 comment

0

That's because you're touching the brick infinite times for second. To fix that add like a Cooldown, a debounce.

2 answers

You'll want to add a debounce, here's the new code.

WinPlace1 = script.Parent
Debounce = false

WinPlace1.Touched:connect(function()
    print(game.Players.LocalPlayer)

if Debounce == false then
Debounce = true

    game.Players.LocalPlayer.leaderstats.point.Value= game.Players.LocalPlayer.leaderstats.point.Value +1

Debounce = false
end
end)

@helperobc That's a good way to do it too

Here's another way (Add a delay):

WinPlace1 = script.Parent
WinPlace1.Touched:connect(function()
script.Disabled = true
    print(game.Players.LocalPlayer)
    wait(3)
    game.Players.LocalPlayer.leaderstats.point.Value= game.Players.LocalPlayer.leaderstats.point.Value +1
wait(5)
script.Disabled = false
end)

1 comment

0

that also works, I guess it really depends on how the developer wants to do it.

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