So I'm making a lumber game, in which there is a function to sell your wood for cash. What I'm trying to do here is for the value of wood inside of the inventory gui to return to 0 and for cash (the leaderstat) to go up reasonably. I just can't figure out what's wrong.
script.Parent.Touched:connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) local cash = plr.leaderstats.Cash local gui = plr.PlayerGui.inventory local woodvalue = gui.frame.wood.value if woodvalue.Value ~= 0 then cash.Value = cash.Value + woodvalue.Value woodvalue.Value = 0 end end)
you have:
if woodvalue.Value ~= 0 then cash.Value = cash.Value + woodvalue.Value woodvalue.Value = 0
I did not get a chance to fully test this but i'd imagine that your error is that roblox does not like having 2 different values to add (try assigning them to variables or do the following)
try replacing the top code with:
if woodvalue.Value ~= 0 then cash.Value += woodvalue.Value woodvalue.Value = 0