So, I wanted to make a thing where you type an username onto a TextBox, and then you hit Enter and it generates the player model of the avatar with that username.
The thing is, when I hit enter, regardless of the username, still spawns the same avatar.
local charname = script.Parent.Charname
local enter = script.Parent.Enter
local char = charname.SurfaceGui.TextBox.ContentText
enter.ClickDetector.MouseClick:Connect(function()
local id = game.Players:GetUserIdFromNameAsync(char)
local model = game.Players:CreateHumanoidModelFromUserId(id)
model.Parent = workspace
model.Name = char
end)
Now, yesterday I thought that the id variable wouldn’t constantly update, and adding a while wait(0) do loop would help, but that just made the character not spawn at all. Then I realized that the script would update when the “Enter” part was clicked, so the while loop wouldn’t do anything, other than break the script. But now I have the same script from earlier, and therefore the same problem.
The character model generator thing is really just a test to improve my scripting, along with pretty much everything on the screenshot. But i’ve yet to find a solution to this, so it would be nice for you guys to help me out.
local charname = script.Parent.Charname
local enter = script.Parent.Enter
enter.ClickDetector.MouseClick:Connect(function()
local char = charname.SurfaceGui.TextBox.ContentText
local id = game.Players:GetUserIdFromNameAsync(char)
local model = game.Players:CreateHumanoidModelFromUserId(id)
model.Parent = workspace
model.Name = char
end)
Yeah you have to use it in a localscript, or fire a remoteevent to the server and pass the edited text thru it from the client, when you edit it on the client, the server still sees the original value, that’s why it doesnt change.
Ok so when you put a new text, it remains client-sided and doesn’t replicate to the server. I’ll try your solution and if it works I’ll mark what you said as the solution.