Help doubling a value that is the result of many values united for a certain amount of time

I’m making a clicker game of sorts that uses pets and stuff.
I use this function here to get the total multiplier between all equipped pets:

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

I’m making a script that would temporarily double that multiplier through a gui button (local script)
Using this script: (The lines in comments are like that since I haven’t made those buttons it looks for yet)

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").Value = getMultiplier(player, "Multiplier1").Value * 2
	script.Parent.Parent.ImageColor3 = Color3.fromRGB(21, 117, 24);
	script.Parent.Text = "Bought";
	wait(60)
	getMultiplier(player, "Multiplier1").Value = getMultiplier(player, "Multiplier1").Value / 2
	character.Humanoid.WalkSpeed = 16
	script.Parent.Parent.ImageColor3 = Color3.fromRGB(46, 255, 53);
	script.Parent.Text = "Buy"
end);

and the function, how would I be able to double this value and reset it back to normal when the timer ends?
Forgot to add that this script currently gives the error:
Players.IsmaelDumDum.PlayerGui.Main.Upgrades.Buttons.ScrollingFrame.2xPetPower1.btn.Button.LocalScript:29: attempt to index number with ‘Value’ - Client - LocalScript:29

Well there’s 2 things.

you return a number here

and try to use .Value on the returned number, causing your error. Remove the .Value's and it’ll work fine. Secondly,

Right here you are dividing it by 2 (and obviously the .Value problem too). The function returns the normal value, so there was no point in that as this would be half of the normal multi.

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);
1 Like

The reason I tried using the “.Value” (I don’t quite understand my decision to do that specifcally either) was because the = returned an error until I added it for some reason.
The error in question:
Players.IsmaelDumDum.PlayerGui.Main.Upgrades.Buttons.ScrollingFrame.2xPetPower1.btn.Button.LocalScript:29: Expected identifier when parsing expression, got ‘=’ - Studio - LocalScript:29
Don’t quite understand why this happens compared to the other errors
Though I believe slightly rewriting that line should fix it so I’ll see what I can do