I've been working on an inventory GUI and I want to change the stats of a player when they click this button. I've tried making my own code but it hasn't worked out so far. This is what I've tried
function click(player)
local stats = player:FindFirstChild("leaderstats")
if stats then
if stats ~= nil then
local cash = stats:findFirstChild("Genie")
end
script.Parent.Visible = false
script.Parent.Parent.Cancel.Visible = false
wait(0.1)
script.Parent.Parent.TextLabel.Text = "."
wait(0.3)
script.Parent.Parent.TextLabel.Text = ".."
wait(0.3)
script.Parent.Parent.TextLabel.Text = "..."
wait(0.3)
script.Parent.Parent.TextLabel.Text = "Purchase successful! This item has been added to your inventory"
wait(3)
print('item')
cash.Value = 1
script.Parent.Parent:TweenPosition(UDim2.new(0, 1500,0, 160), "Out", "Bounce")
end
end
script.Parent.MouseButton1Click:connect(click)

2 comments
I suggest you don't use 'data' in your title, as that makes people assume you're talking about DataStores or Data Persistence. A better word would be 'statistics'
or just leaderstats in this manner