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

GIVE JUST ONE POINTS (OnTouched) - Part ?

Asked by 6 years ago
Edited 6 years ago

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)

0
That's because you're touching the brick infinite times for second. To fix that add like a Cooldown, a debounce. Kiriyato 15 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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)

Ad
Log in to vote
0
Answered by 6 years ago

@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)

0
that also works, I guess it really depends on how the developer wants to do it. helperobc 52 — 6y

Answer this question