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

How can I make a preview for characters in a viewport?

I want to make it so I can insert the username of someone and it will show a preview of the persons Roblox avatar. Here is my code

function preview(id)
	local appearanceModel = game.Players:GetCharacterAppearanceAsync(id)
	script.Parent.ViewportFrame.PlayerPreview:Destroy()
	appearanceModel.Parent = script.Parent.ViewportFrame
end
script.Parent.PreviewButton.MouseButton1Click:Connect(function()
	preview(script.Parent.UsernameSlot.Text)
end)

I keep getting the error, "Unable to cast string to int64". I also want to make it appear in a certain area

1 answer

It's because the property Text of the object is a string, you should convert it to integer with the function tonumber(), inside the () you should put the string, if it can't convert that string into a number, it will return nil, that's why u should check if its not nil and do the rest of the code.

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