Negative number or leaderboard

I am trying to do something like if u go past a part it costs you 10 points to open in but everytime i want to do it my points goes negative



You have to do this

--your code--
if points<0 then
points = 0
--your code--

this is only an example, you have to adapt it

1 Like

The .Touched event is probably triggered more than once. I would create a debounce of some sort to prevent this from happening.

Furthermore, you need to add a check to ensure the player has more than 10 points with something like this:

if points.Value >= 10 then
    -- code here

I would Recommend using math.clamp(), it would make what your doing a lot easier

points.Value = math.clamp(points.Value, 0, math.huge)
-- 0 is the minimum number
-- math.huge is the max number

You can also just use math.max() if you like:

points.Value = math.max(points.Value, 0) -- returns the largest number

Oh yeah sorry, it was just an example :sweat_smile:, I’ll remember that next time, thanks for correcting me :smiley: