**Hello! I am currently having trouble with my script.
This is what it looks like:
local function Name(name) for _, player in pairs(game:GetService("Players"):GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end script.Parent.MouseButton1Click:connect( function() local player = Name(script.Parent.Parent.UsernameHandler.Text) if player then game.Workspace.Value.Value = player script.Parent.Parent.Username.Text = game.Workspace.Value.Value end end )
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:
player = game.Players:FindFirstChild(nameOfPlayerGoesHere)
Instead of having the function.
Here's the code anyway:
players = game:GetService("Players"):GetPlayers() --this function gets the player object when inputed a player name local function Name(name) for _, player in pairs(players) do if player.Name:lower() == name:lower() then return player end end end script.Parent.MouseButton1Click:connect( function() local player = Name(script.Parent.Parent.UsernameHandler.Text) if player then --we found the player object --change the stringValue (?)'s value to be the players name --this is where it was erroring because we were trying to put the player object into the stringValue instead of the player name string. --making the value player.Name will fix the error game.Workspace.Value.Value = player.Name --make text the players name. script.Parent.Parent.Username.Text = game.Workspace.Value.Value end end )