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
7 years ago
Score=0

if workspace.PartScoreBoard.SurfaceGui.Frame.Pin1.BackgroundColor3 == Color3(1, 0, 1) then
    Score = +1
end

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
7 years ago
Edited 7 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.

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

Some extra examples of adding to values IntValues:

local IntVal = script.IntValue --setting a variable for an IntValue located under the script

IntVal.Value = IntVal.Value + 10 --Adding 10 to the value
0
Thank you! Kitorari 266 — 7y
0
Actually, "+1" is not valid in Lua. Link150 1355 — 7y
Ad

Answer this question