So I'm making a script where you sell meat to a trader to get money. The problem is, I'm not sure how to make this type of script and this code is probably wrong. I want it so when you click a textbutton on a ScreenGui, The meat from your leaderstats value gets removed and it gets added as money to the money leaderstat. Can someone help me with this? Thanks!

Here's the script:

local MeatPrice = 10
local Meat = game.Players.LocalPlayer.leaderstats.Meat
local Money = game.Players.LocalPlayer.leaderstats.Money

function Sell()
	local MeatSellPrice = MeatPrice * Meat.Value
	Money = Money.Value + MeatSellPrice.Value
	Meat = 0
end

script.Parent.MouseButton1Down:connect(Sell)

1 comment

0

Is this w/in a LocalScript, or a server-side script? And why're you setting "MeatValue" to 0? B/c the next time you click, the price will no longer go up.