im trying to make a gui where you can sell something here is the code for that
local player = game.Players.LocalPlayer
script.Parent.Parent.TextButton.MouseButton1Click:Connect(function()
local leaderstats = player:WaitForChild("leaderstats")
local Currency = player.leaderstats.Cash
local Melon = player.leaderstats.Watermelons
if Melon.Value > 0 then
Currency.Value = Currency.Value + Melon.Value *5
Melon.Value = 0
end
end)
there is also a part that will add to the thing that you can sell Watermelons in this case
local buttonPressed = false
script.Parent.Touched:Connect(function(hit)
if not buttonPressed then
buttonPressed = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
player.leaderstats.Watermelons.Value = player.leaderstats.Watermelons.Value + 1
wait(1)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
buttonPressed = false
end
end)
but after you sell them if you touch the brick again it adds the to value you had before selling how would i fix this to make the melon count start over a zero

1 comment
And here's an article describing remote events: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events