Hello, i am trying to only get the ID from an asset. What I mean by this is that instead of getting *http://www.roblox.com/asset/?id=***[ID]**, I only want the [ID]. Now I have tried to use string.gsub() to replace it but, that didn’t seem to work because i only got it to work with singular symbols or just one word, I have no idea why.
Also, the initial idea was to get the players hats and then parent them to a new humanoid. Now that didn’t seem to work either because for some reason no matter what i did it wouldn’t set itself to the humanoid although i would use :AddAccessory. It would be great if anyone has a method that works for this
Yep! I actually looked at the this not long ago, but I didn’t read into what it did. So I figured match meant it could only find anything that matches the input.
If you want the player’s hat MeshId then you could do:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
-- save hats for later
local accessories = {}
for _, accessory in pairs(humanoid:GetAccessories()) do
table.insert(accessories, accessory:Clone())
-- get hat ID
local handle = accessory:FindFirstChild("Handle")
print(string.sub(handle.MeshId, 33))
end
end)
end)
flkfv’s idea seems to be a lot better than list guessing the sub number. Since it focuses on removing everything but the numbers. Or else it just prints whatever has 33? Is my guess.