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)

6 comments
So what's the problem? Is the wood value not going to 0 or the cash not going up reasonably or both?
I mean, for one thing, "woodvalue.value" doesn't seem to exist, since you defined woodvalue to be the value of the wood, so you're asking for the value of a value, which doesn't really work. I could be wrong but that's what it looks like.
Woodvalue is a stringvalue inside of a playergui, which i'm trying to contact from this script, which is in a part located in Workspace.
I believe that the problem is that woodvalue isn't answering.
In your definition of woodvalue is wood the StringValue or is value the StringValue?
Woodvalue is the stringvalue. The stringvalue is called "value", so therefore I have to refer it as value.Value.