Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RemoteFunction = script.Parent
- function RemoteFunction.OnServerInvoke(Player, Searched)
- local GetRating = script.Parent.Parent:WaitForChild("GetRating")
- local ShopItems = game.ServerStorage:WaitForChild("ShopItems")
- local Items = {}
- for _, v in pairs(ShopItems:GetChildren()) do
- for _, Item in pairs(v:GetChildren()) do
- if Searched == nil or Item.Name:lower():find(Searched:lower()) then
- local AssetId = Item:FindFirstChild("AssetId")
- if AssetId then
- AssetId = AssetId and "rbxassetid://"..AssetId.Value or ""
- table.insert(Items, {Item.Name, Item.Price.Value, Item.Description.Value, AssetId, v.Name, GetRating:InvokeServer(Item.Name, "Rating") or 0, GetRating:InvokeServer(Item.Name, "Raters") or 0})
- end
- local IconId = Item:FindFirstChild("Icon")
- if IconId then
- IconId = IconId and "rbxassetid://"..IconId.Value or ""
- table.insert(Items, {Item.Name, Item.Price.Value, Item.Description.Value, IconId, v.Name, GetRating:InvokeServer(Item.Name, "Rating") or 0, GetRating:InvokeServer(Item.Name, "Raters") or 0})
- end
- end
- end
- end
- table.sort(Items, function(a, b)
- return string.lower(a[1]) < string.lower(b[1])
- end)
- return Items
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement