Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to change a player's leaderstat with someone writing their name and amount into a textbox?

I have been stumped by this problem, it continually comes up with "Argument 1 missing or nil". I know it's a simple script but I have been stuck for hours. Can anyone debug it and end my suffering please. ;-;

script.Parent.MouseButton1Click:connect(function()
	local directory = script.Parent.Parent
	local player_name = directory["Name"].Text
	local amount = directory["Amount"].Text
    game.Players:FindFirstChild(player_name)["leaderstats"]["Coins"].Value = 
game.Players:FindFirstChild(player_name)["leaderstats"]["Coins"].Value + tonumber(amount)
end)

Basically what I've got is a GUI with a name textbox and an amount textbox, without any text in them and only placeholder text. Heres a picture:

https://gyazo.com/0ffb62c0947a033cc2f82c05af93c304

1 answer

repeat wait() until game.Players.LocalPlayer
local amount = script.Parent.Parent.Amount.Text
game.Players.LocalPlayer.leaderstats.Coins.Value = game.Players.leaderstats.Coins.Value + tonumber(amount)

This discussion is preserved as it was. New answers, comments, and votes are closed.