Advertisement
Guest User

Untitled

a guest
Jun 25th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local RF = ReplicatedStorage:FindFirstChild("GetFaceID") or Instance.new("RemoteFunction", ReplicatedStorage)
  3. RF.Name = "GetFaceID"
  4.  
  5. local faces_cache = {}
  6. local function getFaceId(id)
  7.     -- First, check if the cache already has the ID the user is looking for.
  8.     if faces_cache[id] then return faces_cache[id] end
  9.    
  10.     -- If it's not in the cache, we will attempt to retrieve a valid id
  11.     local asset = game:GetService("InsertService"):LoadAsset(id):GetChildren()[1]
  12.    
  13.     -- Let's make some checks
  14.     if asset then
  15.         game:GetService("Debris"):AddItem(asset, 10) -- remove it after used (save memory)
  16.         if asset:IsA("Decal") then
  17.             -- Put this current ID in the cache so we don't have to user InsertService again in future
  18.             faces_cache[id] = asset.Texture
  19.             return asset.Texture
  20.         end
  21.     end
  22.    
  23.     return false -- inform the client no id was found
  24. end
  25.  
  26. RF.OnServerInvoke = getFaceId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement