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

Add one to Number Value?

Asked by 9 years ago

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

Log in to vote
1
Answered by
nilVector 812 Moderation Voter
9 years ago

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.

0
In other words, you're literally setting the variable to itself plus one. drew1017 330 — 9y
0
Okay thank you so much :) CrispyBrix 113 — 9y
Ad

Answer this question