In this GUI you input the player's name on a TextBox and when you click on a TextButton it should give the player inputted in the TextBox an economy ticket.
This is the script inside the TextButton
1 | function o() |
2 | local text = "game.Players." ..script.Parent.Parent.UsernameBox.Text |
3 | print (text.Name) |
4 | local plr = text |
5 | script.Economy:Clone().Parent = plr.Backpack |
6 | end |
7 |
8 | script.Parent.MouseButton 1 Click:Connect(o) |
It does call the function, I just don't know how to make it find the player I want. Please help me!
Hey, I noticed your problem immediately. It's on line 4.
1 | local plr = text |
You set the variable 'plr' to a string ("game.Players.TEXT"). That doesn't actually locate the player here's your script fixed:
1 | function o() |
2 | local text = game.Players:FindFirstChild(script.Parent.Parent.UsernameBox.Text) -- This checks inside of game.Players for the playername that was entered. It's not a string, and the variable is a player object variable. |
3 | print (text.Name) |
4 | local plr = text |
5 | script.Economy:Clone().Parent = plr.Backpack |
6 | end |
7 |
8 | script.Parent.MouseButton 1 Click:Connect(o) |
Hope this helps and if it does be sure to accept it as the answer :)