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

How do I add to a Value?

Asked by
Kitorari 266 Moderation Voter
8 years ago
1Score=0
2 
3if workspace.PartScoreBoard.SurfaceGui.Frame.Pin1.BackgroundColor3 == Color3(1, 0, 1) then
4    Score = +1
5end

I'm trying to add to the value when when the color of a certain background turns pink.

But so far I'm not getting anywhere, how Do I add to score when something happens?

1 answer

Log in to vote
1
Answered by
StoIid 364 Moderation Voter
8 years ago
Edited 8 years ago

What you did wrong was say Score = +1 which basically means it equals positive 1. When adding to a value you must index it again after the = sign.

1Score=0
2if workspace.PartScoreBoard.SurfaceGui.Frame.Pin1.BackgroundColor3 == Color3(1, 0, 1) then
3    Score = Score + 1
4print(Score)
5end

Some extra examples of adding to values IntValues:

1local IntVal = script.IntValue --setting a variable for an IntValue located under the script
2 
3IntVal.Value = IntVal.Value + 10 --Adding 10 to the value
0
Thank you! Kitorari 266 — 8y
0
Actually, "+1" is not valid in Lua. Link150 1355 — 8y
Ad

Answer this question