Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is ROBLOX detecting my textbox text to always be the same?

Asked by 2 years ago

I am making a game that includes having people type in a username, and it loads that username's avatar onto a dummy. Here's the following code:

script.Parent.MouseButton1Click:Connect(function()
    local PlrName = game.Players:GetUserIdFromNameAsync(script.Parent.Parent.NameBox.Text)

    local Guy = game.Players:CreateHumanoidModelFromUserId(PlrName)

    game.Workspace.Dummy.Head.face.Texture = Guy.Head.face.Texture

    for i, v in pairs(Guy:GetChildren()) do
        if v:IsA("Clothing") or v:IsA("BodyColors") or v:IsA("Accessory") then
            v.Parent = game.Workspace.Dummy
        end
    end
end)

I also will show the gui it holds:

https://gyazo.com/a45733647976d92da536795cc4c9e513

Whenever I use this, it shows me an error saying that the username is incorrect. I did some digging around, and found out it's only locking the text when you first run the game. I figured this out by making the text a username, for example "ROBLOX" before running the game. And it worked. Anyone have an idea for how to help?

Thanks!

0
lordy be, im having the same issue i think where the text label will not change. godspeed dude, hope you get it fixed CheemsTheReaper 2 — 2y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

Instead of using MouseButton1Click, it will fire the function when you click, you do FocusLost, which will fire when the player stops typing.

You should also consider making a error check when you try to create the humanoid model too because sometimes a player's avatar doesn't exist or one of the player accessory doesn't exist, it will error (I'm not sure)

0
I figured out my error, I changed it to a localscript and it worked, but the player accessories fall out of the dummy. Any help? Cyber_gamer91 -3 — 2y
Ad

Answer this question