Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
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)
Ad

Answer this question