HumanoidDesciption won't apply from Textbox?

Basically, what my code is trying to do is when the user types in a userid into the Textbox, the humanoid applies the description of the userid that was typed into the textbox.

This howevery isnt working and I get this error:

Error: "Unable to cast string to int64"

This is my code:

local humanoid = script.Parent.Humanoid
local textbox = game.StarterGui.Main.MainFrame.UsernameIdPicker

humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(textbox.Text))

I am a little new so any easy steps to fix this are appreciated, thank you :smiley:

Try this

local humanoid = script.Parent.Humanoid
local textbox = game.StarterGui.Main.MainFrame.UsernameIdPicker
if tonumber(textbox.Text) then
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(tonumber(textbox.Text)))
end
1 Like

Hello! Thanks for your help.

unfortunately, that didn’t work. But for some reason when I change the text on the TextBox, the text in the Text property doesn’t change, although even when i set the Text property to a value it still won’t work, sorry.

1 Like

Oh yes, it is because you are indexing the StarterGui instead of the PlayerGui.
This looks like a serverscript, try replacing this:

local textbox = game.StarterGui.Main.MainFrame.UsernameIdPicker

with this:

local textbox = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui.Main.MainFrame.UsernameIdPicker
1 Like

the script is located inside the dummy, how do I re-reference playergui?

1 Like

Ah, in this case it would be a little more complex.

You would have to fire a RemoteEvent to the server, in which takes in the text value and applies the description. This is because a Server Script cannot access the player’s UI.

alright, i’ll try experimenting with remote events. If you have any other tips, however please let me know, thanks again :smiley:

1 Like

so I have this so far.

local humanoid = game.Workspace.Dummy.Humanoid
local replicatedstorage = game:GetService("ReplicatedStorage")
local playergui = game.Players.LocalPlayer.PlayerGui
local textbox = playergui.Main.MainFrame.UsernameIdPicker

if tonumber(textbox.Text) then
	replicatedstorage.CharacterChooser:FireServer()
end

I’m just a little confused on how I should write the code that needs to be fired if I stil have to access playergui with a client script

1 Like
local humanoid = game.Workspace.Dummy.Humanoid
local replicatedstorage = game:GetService("ReplicatedStorage")
local playergui = game.Players.LocalPlayer.PlayerGui
local textbox = playergui.Main.MainFrame.UsernameIdPicker

if tonumber(textbox.Text) then
	replicatedstorage.CharacterChooser:FireServer(tonumber(textbox.Text))
end



Server:

local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.CharacterChooser.OnServerEvent:connect(function(id)
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end)

Still doesnt work. Thank you for the help. Sorry for making you do all this work. I can figure it out from here but you are good if you don’t want to help anymore. Thanks again!

What errors are you getting in your output?

no errors, I don’t know what is going on.

Also the Localscript is located in StarterCharacterScripts and the Clientscript is located in the Dummy in Workspace.

Put this in start the UsernameIDPicker as a LocalScript

local humanoid = game.Workspace.Dummy.Humanoid
local replicatedstorage = game:GetService("ReplicatedStorage")
local playergui = game.Players.LocalPlayer.PlayerGui
local textbox = script.Parent

if tonumber(textbox.Text) then
	replicatedstorage.CharacterChooser:FireServer(tonumber(textbox.Text))
end

Put this in ServerScriptService and a normal Script.

local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.CharacterChooser.OnServerEvent:connect(function(id)
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end)

Still did not work. I don’t know why its not applying the description.

Ah my mistake, this should work.

local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.CharacterChooser.OnServerEvent:connect(function(plr,id)
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end)

Still won’t work. (I’m really sorry). Do I have to have a certain setting in studio enabled or something that you know of?

Put in a print to see if its actually being received.

local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.CharacterChooser.OnServerEvent:connect(function(plr,id)
print(plr,id)
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end)

seems like its not getting recieved. what does the (plr,id) part mean? how does it help make the UserId in the textlable give those properties to the dummy?

local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.CharacterChooser.OnServerEvent:connect(function(plr,id)
	print(plr,id)
	game.Workspace.Dummy.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(id))
end)

Tryin’ to get the text from the “UserNameIdPicker” through a server script wont work since when you’re interacting with anythin’ on the client such as a textbox. Nothin’ replicates to the server. Everythin’ is local to you.

To combat this try parenting your local script into the “StarterPlayerScripts” instead and type the following:

local Plr = game.Players.LocalPlayer
local textbox = Plr.PlayerGui:WaitForChild("Main").UserNameIdPicker


local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")



textbox.FocusLost:Connect(function(Send: boolean)
	if Send and tonumber(textbox.Text) then -- // Make sure we pressed "Enter" and the text is a number.
		Event:FireServer(tonumber(textbox.Text))
	end
end)

Now to actually apply the description to the dummy on the server. You’ll need to have a server script inside “ServerScriptService” to listen for when it gets triggered by the client

local Remote = game.ReplicatedStorage.RemoteEvent


local Dummy = game.Workspace.Dummy -- // Refrence your path to your dummy here. Mines workspace.


Remote.OnServerEvent:Connect(function(Player: Player, UserId: number) -- // Player is the player who triggered the remote(OPTIONAL), Second is the arg you sent over.
	local Desc = game.Players:GetHumanoidDescriptionFromUserId(UserId)
	
	
	Dummy.Humanoid:ApplyDescription(Desc)
end)
1 Like