I have a situation where if I type a players username in the text-box the script is supposed to grab the player name I typed and go to Players and find the player and copy the tool in this case a coke into their backpack but I keep getting an error message on line 6.
Error Message From Console: Enter username is not a valid member of Players.
The text-box says Enter username but it shouldn't say error Enter username isn't a player when I changed the text to the players user already.
local a = game.ServerStorage.Items.Drinks -- Item Location
script.Parent.coke.MouseButton1Click:connect(function()
if script.Parent.coke.Text == "Coke" then
local new = a.Coke:Clone() -- Cloning Item
new.Parent = game.Players[script.Parent.Username.Text].Backpack
script.Parent.coke.Text = "Gave item!"
wait(1)
script.Parent.coke.Text = "Coke"
end
end)

2 comments
The Text of Username is "Enter Username," you aren't actually specifying the Username.
Yes, cause the Roblox player is supposed to enter the username themselves its an editable text box so whatever name is inputed to the text box as long as their in the game it should grab them from Players.