I have this block of code here and it takes the money perfectly but then prints this error, "KamikazeJAM108867 is not a valid member of Players" yet im playing the game. Can Someone please help me. Essentially i have a Gui with a playername and an amount, the amount works fine but it has a hard time sending the money to the right player "hence the error" Someone please help!!!
local player = game.Players.LocalPlayer
script.Parent.Send.MouseButton1Down:Connect(function()
print("clicked send")
local playername = script.Parent.Playername.Text
local amount = script.Parent.Amount.Text
if player.leaderstats.Money.Value >= tonumber(amount) then
player.leaderstats.Money.Value = player.leaderstats.Money.Value - tonumber(amount)
wait(2)
game.Players(playername).leaderstats.Money.Value = game.Players(playername).leaderstats.Money.Value + tonumber(amount)
end
if player.leaderstats.Money.Value < tonumber(amount) then
script.Parent.Send.Text = "Not Enough Money"
wait(1)
script.Parent.Send.Text = "Send"
end
end)

2 comments
Is this a LocalScript? Are you using FilteringEnabled?
Yes to both