Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.