So, i made a gui that gives you a better 'backpack' with X spaces for an amount of money...the problem is , the spaces becomes 100000 , the money is taken away but.....it doesn't work, i mean it's still the default option, and if i sell the items, i get the money back...
Here's the code
-- Lets players click a button to buy an upgrade that increases MaxSpaces
local buyButton = script.Parent
-- Variables for the upgrade
local newSpaces = 1000000
local upgradeCost = 100000000
local function giveUpgrade(player)
print("Someone clicked the button")
local player = game.Players.LocalPlayer
-- Get's the player's leaderboard to get other IntValues
local playerStats = player:FindFirstChild("leaderstats")
-- Gets the player's money and spaces to make changes
local playerGold = playerStats:FindFirstChild("Gold")
local playerSpaces = playerStats:FindFirstChild("Spaces")
-- Checks if player has enough money to afford the upgrade
if playerGold.Value >= upgradeCost then
print("Player can buy item")
-- Subtract the item's cost from the player's money
playerGold.Value = playerGold.Value - upgradeCost
playerSpaces.Value = newSpaces
end
end
script.Parent.Activated:Connect(giveUpgrade)

4 comments
Why are you defining a parameter inside of a function? That literally defeats the purpose of having a parameter.
Dunno..Still, i don't think that's the problem.
Maybe because everything is local?? Is this a normal script or a localscript?
If he's using the LocalPlayer property of the Players service, then yes, everthing is local.