**Hello! I am currently having trouble with my script.
This is what it looks like:
01 | local function Name(name) |
02 | for _, player in pairs (game:GetService( "Players" ):GetPlayers()) do |
03 | if player.Name:lower() = = name:lower() then |
04 | return player |
05 | end |
06 | end |
07 | end |
08 |
09 |
10 | script.Parent.MouseButton 1 Click:connect( |
11 | function () |
12 | local player = Name(script.Parent.Parent.UsernameHandler.Text) |
13 | if player then |
14 | game.Workspace.Value.Value = player |
15 | script.Parent.Parent.Username.Text = game.Workspace.Value.Value |
16 | end |
17 | end |
18 | ) |
When I try to submit the username, the output says 13:08:25.136 - Players.raid6n.PlayerGui.TableFinder.Background.TextButton.LocalScript:18: bad argument #3 to 'Value' (string expected, got Object)"
Thank you for reading, have a great day.****
Here's the script, but I'm not sure why you are getting the player object. Either way, you can get the player object by doing this:
1 | player = game.Players:FindFirstChild(nameOfPlayerGoesHere) |
Instead of having the function.
Here's the code anyway:
01 | players = game:GetService( "Players" ):GetPlayers() |
02 |
03 | --this function gets the player object when inputed a player name |
04 | local function Name(name) |
05 | for _, player in pairs (players) do |
06 | if player.Name:lower() = = name:lower() then |
07 | return player |
08 | end |
09 | end |
10 | end |
11 |
12 |
13 | script.Parent.MouseButton 1 Click:connect( function () |
14 | local player = Name(script.Parent.Parent.UsernameHandler.Text) |
15 |