The script is meant to apply the face you paste into the textbox, onto your face. I’m having trouble with it because anytime anyone paste anything, their face is invisible. I think I know why this is the case, but I need help either converting the asset id into a decal id upon applying or find a solution similar to that.
Some feedback and a little help would be appreciated,
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local TextBox = script.Parent.Parent.FaceID
script.Parent.MouseButton1Up:Connect(function()
local head = character:WaitForChild("Head")
local face = head:FindFirstChildWhichIsA("Decal")
local id = TextBox.Text:match("%d+") -- pulls the numeric ID
if face and id then
print(id)
face.Texture = "http://www.roblox.com/asset/?id=" .. id
end
end)
You’re supposed to be able to copy an asset ID, and paste it into the text box. Then the face is pasted on you. You used a texture ID. Which works but i’d really prefer if it was a face from the catalog.
Try loading the asset with insertservice, finding the decal in the asset, save it’s texture id, then destroy the inserted asset, create a decal on the player’s face and add the texture id you found from the decal. This should work.
Are you sure this works? Is HttpService allowed to reach that resource? I would see this working in a bash or python script but not in roblox studio, especially on the server-side.
Nvm, you’re right it doesn’t, the ids just matched…
I guess your method works the best, however he’d have to have a server sided script added to have access to InsertService. Wrote a quick test sample script for that:
local IS = game:GetService("InsertService")
game.ReplicatedStorage.event.OnServerEvent:Connect(function(player, id : number)
if tonumber(id) then
local success, asset = pcall(function()
return IS:LoadAsset(id)
end)
if success then
if asset:FindFirstChildWhichIsA("Decal") then
game.ReplicatedStorage.event:FireClient(player, asset.Texture)
elseif asset:FindFirstChildWhichIsA("ImageLabel") then
game.ReplicatedStorage.event:FireClient(player, asset.Image)
end
asset:Destroy()
else
warn("Failed to fetch asset: "..tostring(id))
end
end
end)
Yeah https://assetdelivery.roblox.com is a good way to get FileMeshs for a plugin for example. Here is what he should do to his scripts. Add the following code to the local script
--Local Script in your button
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local button = script.Parent -- your decalApply button
local textBox = button.Parent:WaitForChild("FaceInputBox") --This would be your text box you put the id in
local applyFaceEvent = ReplicatedStorage:WaitForChild("ApplyFaceEvent")--Event to send the id to the server script
button.MouseButton1Click:Connect(function()
local assetId = tonumber(textBox.Text)
if assetId then
applyFaceEvent:FireServer(assetId)
else
warn("Invalid Asset ID entered.")
end
end)
Add a server script with the following code
--Server Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InsertService = game:GetService("InsertService")
local applyFaceEvent = ReplicatedStorage:WaitForChild("ApplyFaceEvent")
applyFaceEvent.OnServerEvent:Connect(function(player, assetId) --hearing the call from the client
if not tonumber(assetId) then
warn("Invalid Asset ID")
return
end
local success, insertedAsset = pcall(function()
return InsertService:LoadAsset(assetId) -- inserting a asset with the id we got from the client
end)
if not success or not insertedAsset then
warn("Failed to load asset with ID:", assetId)
return
end
-- Try to find the Decal inside the asset
local decal = insertedAsset:FindFirstChildWhichIsA("Decal", true) -- getting a decal from the asset
if not decal then
warn("No Decal found in asset")
insertedAsset:Destroy() -- if no decal destroy the asset
return
end
local textureId = decal.Texture -- getting the texture id from the decal
insertedAsset:Destroy() -- destroying the asset
-- Apply the texture to the character's face
local character = player.Character or player.CharacterAdded:Wait()
local head = character:FindFirstChild("Head")
if not head then return end
local existingFace = head:FindFirstChildOfClass("Decal")
if existingFace then
existingFace:Destroy()
end
-- Asset going on the head
local newFace = Instance.new("Decal")
newFace.Name = "Face"
newFace.Face = Enum.NormalId.Front
newFace.Texture = textureId
newFace.Parent = head
print("Applied texture:", textureId)
end)
This method 100% works:) Roblox should add texture ids to marketplace service like asset ids.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local TextBox = script.Parent.Parent.FaceID
script.Parent.MouseButton1Up:Connect(function()
local head = character:WaitForChild("Head")
local face = head:FindFirstChildWhichIsA("Decal")
local id = TextBox.Text:match("%d+") -- pulls the numeric ID
if face and id then
print(id)
face.Texture = "http://www.roblox.com/asset/?id=" .. tostring(id) -- Changes the numeric data to string so that it can be correctly recognized.
end
end)
This should work. [I put a double hyphenation for the part where you were mistaken, and added clarity. Hope this helps!]
Annex: This is a localscript so it’s client-sided. Other players on the server will not see your face change unless you intend to use remote events and a serversided script.
After making a remote event, and applying the scripts. this same error comes up no matter what you put in it. A decal, asset or texture. Even if it IS valid, like a face.