This consists of two parts, a local script in the frame where the text box resides, and a script in ServerScriptService
local textbox = script.Parent.FaceId
local textButton = script.Parent.Sender2
local event = game.ReplicatedStorage.Events:WaitForChild("FaceEvent")
textButton.MouseButton1Click:Connect(function()
event:FireServer(textbox.Text)
end)
Here's the server script
local event = game.ReplicatedStorage.FaceEvent
local insertService = game:GetService("InsertService")
event.OnServerEvent:Connect(function(player, id)
local model = insertService:LoadAsset(id)
model.Parent = workspace
local asset = model:GetChildren()
if asset:IsA("Texture") then
if player.Character.Head.face.Texture:FindFirstChildWhichIsA("Texture") then
player.Character.Head.face.Texture:FindFirstChildWhichIsA("Texture"):Destroy()
end
asset.Parent = player.Character
end
end)
For anybody wondering, the code is more or less copied from the same script I used to insert hats onto a character, hence the weird names
