local plrname = script.Parent.Parent.TextBox.Text
script.Parent.MouseButton1Click:Connect(function()
for i,Player in pairs(game.Players:GetPlayers()) do
if Player.Name == plrname then
Player.leaderstats.Gold.Value = Player.leaderstats.Gold.Value + 10000
end
end
end)
This is my script for part of my custom admin panel. This button is supposed to give whatever player typed into the textbox 10,000 Gold, but it doesn't work. If you're wondering why I decided to use an i, v in pairs loop, it's because I don't want the script to break if it can't find the player. I'm not sure why it's not working, so if anyone knows, help would be greatly appreciated. There are no errors in the output, either, as far as I can tell. Help appreciated, thanks.

2 comments
GUIs are Localscripts.
you can't do this from a localscript, you should use RemoteEvents. https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events