Why isn't my value getting doubled?
The UpgradeAmount --Value is 2, so it should get doubled when I purchase the upgrade.
How can I fix this?
The area where the value should get doubled lies at line 13
repeat wait()
Player = game.Players.LocalPlayer
Button = script.Parent
Cost = script.Parent.Price.Value
Money = Player.leaderstats.Money
UpgradeAmount = script.Parent.Parent.UpgradeIncome.UpgradeAmount
until
Button.MouseButton1Down:connect(function(purchase)
if Money.Value > (Cost - 1) then
Money.Value = Money.Value - Cost
script.Parent.Parent.ClickForMoney.MoneyToGain.Value = script.Parent.Parent.ClickForMoney.MoneyToGain.Value * UpgradeAmount.Value
local PurchaseCounter = game.Players:FindFirstChild(Player.Name):FindFirstChild("PurchaseCounterFor"..Player.Name)
local TotalPurchases = script.Parent.Parent.Parent.TotalPurchases
print(
"Cha-Ching! "..script.Parent.Name.." Was Bought By "..Player.Name.."! "
..script.Parent.Price.Value.."$ Has Been Charged From "..Player.Name..
"'s In-Game Money! Enjoy Your "..script.Parent.Name..", "..Player.Name.."!"
)
PurchaseCounter.Value = PurchaseCounter.Value + 1
TotalPurchases.Text = "Total Purchases: "..PurchaseCounter.Value
local Sound = Instance.new("Sound") --The Cha-Ching Sound
Sound.SoundId = "http://www.roblox.com/asset/?id=131886985"
Sound.Parent = Player.PlayerGui.SoundFixGui
local SoundToggle = game.Players:FindFirstChild(Player.Name):FindFirstChild("SoundOnOffFor"..Player.Name)
if SoundToggle.Value then
Sound:Play()
wait(1)
Sound:Remove()
else
Sound:Stop()
wait(1)
Sound:Remove()
end
print("Money Increase Per Click Increased By *"..script.Parent.Parent.UpgradeIncome.UpgradeAmount.Value.." For: "..Player.Name)
end
wait(0.001)
script.Parent:Destroy()
print("UpgraderGui#1 Destroyed After Purchase By: "..Player.Name)
end)

3 comments
The SoundToggle is an IntValue which is made automatically with another script I have. One SoundToggle is made for each Player in the server, and is put into the localplayer --game.Players:FindFirstChild(Player.Name) / inside the player who newly joined the server. By clicking on the Sound On / Sound Off Buttons in the Gui, they are able to turn ON / OFF the sound that plays when they buy the item
Oh, I see now, thanks!
Your solution to my problem has not worked unfortunately. Please note: The coding is inside a localscript. I have even tried to Clone() the IntValue I want to upgrade and Destroy() the old one and then changing the value of the cloned one to the value I want it to be and then setting its parent to where the old IntValue was. Any other ideas on how to fix this problem?