Expected identifier when parsing expression, got ‘=’ error

I’m using this code to multiply a total value result of many values for a short amount of time through a local script in a text button:

local players = game:GetService("Players")
local player = game.Players.LocalPlayer

local cost = 15000

function getMultiplier(Player, multiplierName)
	local Multi = 0
	for i,v in pairs(Player.Pets:GetChildren()) do
		if v.Equipped.Value == true then
			Multi = Multi + v[multiplierName].Value
		end
	end
	return Multi
end

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Text == "Bought" then
		return;
	end;
	--if script.Parent.Parent.Parent.Parent:WaitForChild("2xPetPower2") == "Bought" then
	--	return;
	--end;
	--if script.Parent.Parent.Parent.Parent:WaitForChild("2xPetPower3") == "Bought" then
	--	return;
	--end;
	local character = player.Character or player.CharacterAdded:Wait()
	local leaderstats = players.LocalPlayer:WaitForChild("leaderstats")
	leaderstats:WaitForChild("Coins").Value = leaderstats:WaitForChild("Coins").Value - cost
	getMultiplier(player, "Multiplier1") = getMultiplier(player, "Multiplier1") * 2
	script.Parent.Parent.ImageColor3 = Color3.fromRGB(21, 117, 24);
	script.Parent.Text = "Bought";
	wait(60)
	getMultiplier(player, "Multiplier1") = getMultiplier(player, "Multiplier1")
	character.Humanoid.WalkSpeed = 16
	script.Parent.Parent.ImageColor3 = Color3.fromRGB(46, 255, 53);
	script.Parent.Text = "Buy"
end);

Everytime I do this an error ocurrs:
Players.IsmaelDumDum.PlayerGui.Main.Upgrades.Buttons.ScrollingFrame.2xPetPower1.btn.Button.LocalScript:29: Expected identifier when parsing expression, got ‘=’ - Studio - LocalScript:29
I’ve tried many things but both of the instances of the multiplier being set to another value return this error, how would I go about fixing this?

getMultiplier(player, "Multiplier1") = getMultiplier(player, "Multiplier1") * 2

This is your issue. Instead, set the returned value as a variable if you want to update a returned value.

local current = getMultiplier(player, "Multiplier1")
current = getMultiplier(player, "Multiplier1") * 2
4 Likes

you can shorten it and do:

local current = getMultiplier(player, "Multiplier1") * 2
1 Like