#cookie clicker multiplier button
10 messages · Page 1 of 1 (latest)
--MultiplierButton local script
local multiplierButton = script.Parent
local costLabel = multiplierButton:FindFirstChild("CostLabel1")
local cookies = player:WaitForChild("leaderstats"):WaitForChild("Cookies")
local upgradeMultiplier = 2
local costMultiplier = 3
local upgradeCost = 10 -- Initial upgrade cost
local function UpdateCostLabel()
costLabel.Text = "2x: " .. upgradeCost -- Update the text of the CostLabel
end
local function PurchaseUpgrade()
if cookies.Value >= upgradeCost then
cookies.Value = cookies.Value - upgradeCost
upgradeCost = upgradeCost * costMultiplier -- Update the upgrade cost
upgradeMultiplier = upgradeMultiplier * 2 -- Multiply the upgradeMultiplier by 2
player:WaitForChild("ClickValue").Value = player:WaitForChild("ClickValue").Value * 2 -- Multiply the clickValue by 2
print("Upgrade purchased! Cost: " .. upgradeCost)
UpdateCostLabel() -- Call the function to update the CostLabel
return true -- Return true to indicate the upgrade was purchased
else
print("Not enough cookies to purchase the upgrade.")
return false -- Return false to indicate the upgrade was not purchased
end
end
local function OnMultiplierButtonClicked()
PurchaseUpgrade()
end
multiplierButton.MouseButton1Click:Connect(OnMultiplierButtonClicked)
UpdateCostLabel() -- Call the function initially to set the correct starting cost
-- Add this part to the bottom of the script
local module = {}
module.PurchaseUpgrade = PurchaseUpgrade
module.upgradeMultiplier = upgradeMultiplier
module.UpdateCostLabel = UpdateCostLabel
return module```
--CookieButton local script
local cookieButton = script.Parent -- Reference to the ImageButton
local cookieCounterLabel = player.PlayerGui.CookieGui.CookieCounterLabel
local cookies = player:WaitForChild("leaderstats"):WaitForChild("Cookies")
local UpgradeModule = require(game:GetService("ServerScriptService").UpgradeModule)
local MultiplierButtonScript = require(player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton:FindFirstChild("MultiplierButton"))
local clickValue = 1
local hasUpgrade = false -- Track whether the upgrade is purchased
local function UpdateCookieCounter()
if hasUpgrade then
cookies.Value = cookies.Value + clickValue * UpgradeModule.upgradeMultiplier
else
cookies.Value = cookies.Value + clickValue
end
cookieCounterLabel.Text = "Cookies: " .. cookies.Value
end
local function OnButtonClicked()
UpdateCookieCounter()
end
cookieButton.MouseButton1Click:Connect(OnButtonClicked)
local multiplierButton = player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton
multiplierButton.MouseButton1Click:Connect(function()
hasUpgrade = UpgradeModule.PurchaseUpgrade(cookies.Value)
MultiplierButtonScript.UpdateCostLabel() -- Call the exported function from MultiplierButtonScript
end)
local multiplierButton = player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton
multiplierButton.MouseButton1Click:Connect(function()
hasUpgrade = UpgradeModule.PurchaseUpgrade(cookies.Value)
MultiplierButtonScript.UpdateCostLabel()
print("MultiplierButtonScript.UpdateCostLabel called") -- Add this line to check if the function is being called
end)```
whats the problem?
it doesnt give you the multiplier
here is my new script that still aint working
cookie gui local script
local player = game.Players.LocalPlayer
local cookieButton = player.PlayerGui.CookieGui.CookieButton
local cookieCounterLabel = player.PlayerGui.CookieGui.CookieCounterLabel
local cookies = 0
local function UpdateCookieCounter()
cookies = cookies + 1
cookieCounterLabel.Text = "Cookies: " .. cookies
-- Update the leaderstats value
player.leaderstats.Cookies.Value = cookies
end
local function OnButtonClicked()
UpdateCookieCounter()
end
cookieButton.MouseButton1Click:Connect(OnButtonClicked)
-- Add leaderstats to the player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cookiesStat = Instance.new("IntValue")
cookiesStat.Name = "Cookies"
cookiesStat.Value = cookies
cookiesStat.Parent = leaderstats```
cookiebutton local script
local player = game.Players.LocalPlayer
local cookieButton = script.Parent -- Reference to the ImageButton
local cookieCounterLabel = player.PlayerGui.CookieGui.CookieCounterLabel
local cookies = player:WaitForChild("leaderstats"):WaitForChild("Cookies")
local UpgradeModule = require(game:GetService("ServerScriptService").UpgradeModule)
local MultiplierButtonScript = require(player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton:FindFirstChild("MultiplierButton"))
local clickValue = 1
local hasUpgrade = false -- Track whether the upgrade is purchased
local function UpdateCookieCounter()
if hasUpgrade then
cookies.Value = cookies.Value + clickValue * UpgradeModule.upgradeMultiplier
else
cookies.Value = cookies.Value + clickValue
end
cookieCounterLabel.Text = "Cookies: " .. cookies.Value
end
local function OnButtonClicked()
UpdateCookieCounter()
end
cookieButton.MouseButton1Click:Connect(OnButtonClicked)
local multiplierButton = player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton
multiplierButton.MouseButton1Click:Connect(function()
hasUpgrade = UpgradeModule.PurchaseUpgrade(cookies.Value)
MultiplierButtonScript.UpdateCostLabel() -- Call the exported function from MultiplierButtonScript
end)
local multiplierButton = player.PlayerGui.ScreenGui.MainFrame.ShopGui.MultiplierButton
multiplierButton.MouseButton1Click:Connect(function()
hasUpgrade = UpgradeModule.PurchaseUpgrade(cookies.Value)
MultiplierButtonScript.UpdateCostLabel()
print("MultiplierButtonScript.UpdateCostLabel called") -- Add this line to check if the function is being called
end)```
multiplierbutton local script
local player = game.Players.LocalPlayer
local multiplierButton = script.Parent
local costLabel = multiplierButton:FindFirstChild("CostLabel1")
local cookies = player:WaitForChild("leaderstats"):WaitForChild("Cookies")
local upgradeMultiplier = 2
local costMultiplier = 3
local upgradeCost = 10 -- Initial upgrade cost
local function UpdateCostLabel()
costLabel.Text = "2x: " .. upgradeCost -- Update the text of the CostLabel
end
local function PurchaseUpgrade()
if cookies.Value >= upgradeCost then
cookies.Value = cookies.Value - upgradeCost
upgradeCost = upgradeCost * costMultiplier -- Update the upgrade cost
upgradeMultiplier = upgradeMultiplier * 2 -- Multiply the upgradeMultiplier by 2
player:WaitForChild("ClickValue").Value = player:WaitForChild("ClickValue").Value * 2 -- Multiply the clickValue by 2
print("Upgrade purchased! Cost: " .. upgradeCost)
UpdateCostLabel() -- Call the function to update the CostLabel
return true -- Return true to indicate the upgrade was purchased
else
print("Not enough cookies to purchase the upgrade.")
return false -- Return false to indicate the upgrade was not purchased
end
end
local function OnMultiplierButtonClicked()
PurchaseUpgrade()
end
multiplierButton.MouseButton1Click:Connect(OnMultiplierButtonClicked)
UpdateCostLabel() -- Call the function initially to set the correct starting cost
-- Add this part to the bottom of the script
local module = {}
module.PurchaseUpgrade = PurchaseUpgrade
module.upgradeMultiplier = upgradeMultiplier
module.UpdateCostLabel = UpdateCostLabel
return module