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

How to make a dummy that changes appearance, but there is an error?

Asked by 2 years ago

Hi! I want to create a TextBox that you can enter an username for change the appearance of a Dummy. First, the code changes the dummy to the text of the TextBox (I put the username before run the game, but when I edited text if I were player it doesn't work). But there is an error in the last line. Error: Attempt to connect failed: Passed value is not a function.

local Players = game:GetService("Players")
local Dum = workspace.Dummy
local Username = script.Parent.Text
local ID = Players:GetUserIdFromNameAsync(Username)
local function CreateOfflineCharacter(UserID, Dummy)

    local Appearance = Players:GetHumanoidDescriptionFromUserId(UserID)
    Dummy.Humanoid:ApplyDescription(Appearance)
end

script.Parent:GetPropertyChangedSignal("Text"):Connect(CreateOfflineCharacter(ID, Dum))

I think I'm not using correctly the function. I tried script.Parent:GetPropertyChangedSignal("Text"):Connect(function() CreateOfflineCharacter(ID, Dum) end) This alternative code don't give me errors, however it doesn't do anything. Can you help me, please?

1 answer

Log in to vote
0
Answered by 2 years ago

Try detecting when the player presses the Enter key on the text box.

local Players = game:GetService("Players")
local Dum = workspace.Dummy
local Username = script.Parent.Text
local ID = Players:GetUserIdFromNameAsync(Username)
local function CreateOfflineCharacter(UserID, Dummy)

    local Appearance = Players:GetHumanoidDescriptionFromUserId(UserID)
    Dummy.Humanoid:ApplyDescription(Appearance)
end

script.Parent.FocusLost:Connect(function(enterPressed) 
    if enterPressed then
        CreateOfflineCharacter(ID, Dum) 
    end
end)
Ad

Answer this question