Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RF = ReplicatedStorage:FindFirstChild("GetFaceID") or Instance.new("RemoteFunction", ReplicatedStorage)
- RF.Name = "GetFaceID"
- local faces_cache = {}
- local function getFaceId(id)
- -- First, check if the cache already has the ID the user is looking for.
- if faces_cache[id] then return faces_cache[id] end
- -- If it's not in the cache, we will attempt to retrieve a valid id
- local asset = game:GetService("InsertService"):LoadAsset(id):GetChildren()[1]
- -- Let's make some checks
- if asset then
- game:GetService("Debris"):AddItem(asset, 10) -- remove it after used (save memory)
- if asset:IsA("Decal") then
- -- Put this current ID in the cache so we don't have to user InsertService again in future
- faces_cache[id] = asset.Texture
- return asset.Texture
- end
- end
- return false -- inform the client no id was found
- end
- RF.OnServerInvoke = getFaceId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement