I am making a name system for my game. It makes a button for every name in the table, and it is supposed to change the value inside the player to the name that is pressed. I get an error saying "invalid argument #3(expected string, got instance)"
localscript inside the gui
wait(2.5)
local Button = game.ReplicatedStorage:WaitForChild("Name")
local Frame = script.Parent
local Names = {"Arya", "Amber", "Imaaad", "Rhiann", "Atlanta", "Aj", "Noa", "Romany", "Layton", "Cruz", "Helen", "Shannay", "Mattew", "Katerina", "Subhaan", "Joesph", "Shaya", "Tymoteusz", "Taliyah", "Mateo", "Aimie", "Irene", "Naomi", "Sorrel", "Ptolemy", "Mathilde", "Nola", "Amari", "Zayd", "Nick", "Pauline", "Adi", "Corbyn", "Lowenna", "Ashwin", "Emilio", "Nathaniel", "Yara", "Aniqa", "Zhen", "Connel", "Henry", "Bob", "Trevor", "Ray", "Suzy", "Devante", "Chantal", "Bryn", "Cariad", "Juliet", "Leila"}
local player = game.Players.LocalPlayer
for i,v in pairs(Names) do
local copy = Button:Clone()
copy.Name = v
copy.Text = v
copy.Parent = Frame
end
while wait(0.01) do
for i,v in pairs(Names) do
local currentbutton = Frame:FindFirstChild(v)
if currentbutton:IsA("TextButton") then
currentbutton.MouseButton1Up:Connect(function()
local ChosenName = currentbutton.Name
game.ReplicatedStorage.NameEvent:FireServer(player, ChosenName)
wait(1)
end)
end
end
end
ServerScript that is supposed to change the value
game.ReplicatedStorage.NameEvent.OnServerEvent:Connect(function(player, ChosenName)
local Name = player:FindFirstChild("PlayerName")
Name.Value = ChosenName
end)

1 comment
Thanks! It worked lol.