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