I have a shop and a buy button here for buying stuff. It gives the player the weapon but does not subtract your money.
IMPORTANT - The output says:
function start :)
Buying... :)
That costs 1000
You had 10000
You now have 9000
Tool Found
When pressing the button again it says the exact same thing
local but = script.Parent
plr = game.Players.LocalPlayer
local bag = plr:WaitForChild('Backpack')
local tool
local price
local bux
but.MouseButton1Click:Connect(function()
print('function start :)')
price = but.Parent.Cost.Text
price = tonumber(price)
tool = but.Parent.ItemName.Text
bux = plr.leaderstats.SeerBux.Value
if bux >= price then
print('Buying... :)')
print('That costs '..price)
print('You had '..bux)
plr.leaderstats.SeerBux.Value = plr.leaderstats.SeerBux.Value - price
print('You now have '..bux)
local Tool = game.ReplicatedStorage.Tool:WaitForChild(tool)
if Tool then
print('Tool Found :)')
local ToolGive = Tool:Clone()
ToolGive.Parent = bag
else
print('Tool Not Located :(')
end
else
print('Not Enough Money :(')
print('You Need '..price)
end
end)

2 comments
this is a LocalScript. To subtract their money you need to change the value on the Server with a RemoteEvent
ok