-1

I am trying to make a script in Google Scripts with checkboxes, when my cells C9 and D8 are true (checkbox checked), should sum 1. However, even with the checkboxes unchecked it is still summing 1. Which is the problem? Thanks!

function sum() {

var sheet = SpreadsheetApp.getActiveSheet();
var player = sheet.getRange('C9').getValue();
var action = sheet.getRange('D8').getValue();
var value = sheet.getRange('D9').getValue();

if (player = true && action = true){
  sheet.getRange('D9').setValue(value+1);
  }
else {
  sheet.getRange('D9').setValue(value);
  }}
Rubén
  • 34,714
  • 9
  • 70
  • 166

1 Answers1

1

On Google Apps Script, because it's based on JavaScript, a single = means variable value assignation. To do an equality comparison instead of = use == (abstract equality) or === (strict equality).

Rubén
  • 34,714
  • 9
  • 70
  • 166