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

Add one to Number Value?

So I need it so every time a player walks on this button a number value in their GUI will change. It's supposed to go up by one every time the player walks on it. Instead it does nothing. There seems to be something wrong with the way I am changing the number value I just don't know how to properly do it.

script.Parent.Touched:connect(function(player) -- 'player' is the part that touches it, nothing else.. So it's either going to be the Left Leg or the Right Leg of the player..
plr = game.Players:FindFirstChild(player.Parent.Name) -- This is going to get the player itself
    plr.PlayerGui.Points.FPoints.Points.Value =  +  1 -- now this should change the GUI for the player.
end)

The way I am changing the Value seems to be wrong idk how to change it though.

1 answer

✓ Accepted answer

In line 3,

plr.PlayerGui.Points.FPoints.Points.Value =  +  1

should be

plr.PlayerGui.Points.FPoints.Points.Value =  plr.PlayerGui.Points.FPoints.Points.Value  + 1

In computer programming, you have to take the value of the current integer and add it by one & set it equal to the integer variable or desired object storing an integer variable.

2 comments

0

In other words, you're literally setting the variable to itself plus one.

0

Okay thank you so much :)

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