Hello, I'm having trouble setting up my upgrade shop for the game i'm making. Im trying to make it have 4 tiers per upgrade. Keep in mind the totalUpgrades value is for unlocking the last upgrade which is achieved by buying 3 upgrades.
local replicatedStorage = game:GetService("ReplicatedStorage") local localPlayer = game.Players.LocalPlayer local timesBought = 0 local totalUpgrades = script.Parent.Parent.Parent.UpgradeValue.Value if timesBought == 4 then print("Maxed Out!") script.Parent.Text = "Maxed!" elseif timesBought == 3 then script.Parent.MouseButton1Click:Connect(function() if localPlayer.leaderstats.Coins.Value >= 1200 then localPlayer.PlayerData.FireDMG.Value = 45 localPlayer.leaderstats.Coins.Value = (localPlayer.leaderstats.Coins.Value - 1200) timesBought = timesBought + 1 totalUpgrades = totalUpgrades + 1 else print("no money!") end end) elseif timesBought == 2 then script.Parent.MouseButton1Click:Connect(function() if localPlayer.leaderstats.Coins.Value >= 650 then localPlayer.PlayerData.FireDMG.Value = 30 localPlayer.leaderstats.Coins.Value = (localPlayer.leaderstats.Coins.Value - 650) script.Parent.Text = "Damage: $1200" timesBought = timesBought + 1 totalUpgrades = totalUpgrades + 1 else print("no money!") end end) elseif timesBought == 1 then script.Parent.MouseButton1Click:Connect(function() if localPlayer.leaderstats.Coins.Value >= 400 then localPlayer.PlayerData.FireDMG.Value = 15 localPlayer.leaderstats.Coins.Value = (localPlayer.leaderstats.Coins.Value - 400) script.Parent.Text = "Damage: $650" timesBought = timesBought + 1 totalUpgrades = totalUpgrades + 1 else print("no money!") end end) elseif timesBought == 0 then script.Parent.MouseButton1Click:Connect(function() if localPlayer.leaderstats.Coins.Value >= 200 then localPlayer.PlayerData.FireDMG.Value = 5 localPlayer.leaderstats.Coins.Value = (localPlayer.leaderstats.Coins.Value - 200) script.Parent.Text = "Damage: $400" timesBought = timesBought + 1 totalUpgrades = totalUpgrades + 1 else print("no money!") end end) end
solved it literally after posting this. I need the script button function on the outside and the timesBought on the inside :D