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)
Well you don't need if
:statsthen
twice...
script.Parent.MouseButton1Down:connect(function()) local player = game.Players.LocalPlayer local stats = player:FindFirstChild("leaderstats") if stats then local cash = stats:findFirstChild("Genie") 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 end
Your end was also misplaced, let me know if this works, if it does please accept my answer