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

How do I add to a Value?

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

✓ Accepted answer

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

2 comments

0

Thank you!

0

Actually, "+1" is not valid in Lua.

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