Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local library = loadstring(game:HttpGet("https://pastebin.com/raw/7Z6TzFnv", true))()
- local plr = game.Players.LocalPlayer
- local openCrystalRemote = game.ReplicatedStorage.rEvents:FindFirstChild("openCrystalRemote")
- local sellTrailEvent = game.ReplicatedStorage.rEvents:FindFirstChild("sellTrailEvent")
- local sellPetEvent = game.ReplicatedStorage.rEvents:FindFirstChild("sellPetEvent")
- local rarityId = {
- Basic = 1,
- Advanced = 2,
- Rare = 3,
- Epic = 4,
- Unique = 5
- }
- function GetAvailableCrystals()
- local Tab = workspace.mapCrystalsFolder:GetChildren()
- local crystals = {}
- for Index = 1, #Tab do
- crystals[Index] = Tab[Index].Name
- end
- return crystals
- end
- function BuyCrystal(name, amount, minrarity)
- local minrarity = rarityId[minrarity] or rarityId["Basic"]
- local crystal = workspace.mapCrystalsFolder:FindFirstChild(name)
- if crystal then
- for i = 1, amount do
- local itemName, itemRarity = openCrystalRemote:InvokeServer("openCrystal", name)
- if itemName then
- local itemRarity = itemRarity or "Unknown"
- warn("Opened ".. name .. ", got ".. itemName .. " (" .. itemRarity.. ")")
- if rarityId[itemRarity] < minrarity then
- sellTrailEvent:FireServer("sellTrail", plr.trailsFolder[itemRarity][itemName])
- end
- else
- warn("Inventory full!")
- return
- end
- end
- else
- error("Crystal not found")
- end
- end
- function SellAll(rarity)
- for _,Folder in next, plr.trailsFolder:GetChildren() do
- if rarityId[Folder.Name] <= rarityId[rarity] then
- for _,trail in next, Folder:GetChildren() do
- sellTrailEvent:FireServer("sellTrail", trail)
- warn("Sold trail " .. trail.Name .." (" .. trail.Parent.Name .. ")")
- end
- end
- end
- for _,Folder in next, plr.petsFolder:GetChildren() do
- if rarityId[Folder.Name] <= rarityId[rarity] then
- for _,pet in next, Folder:GetChildren() do
- sellPetEvent:FireServer("sellPet", pet)
- warn("Sold pet " .. pet.Name .." (" .. pet.Parent.Name .. ")")
- end
- end
- end
- end
- local mainwindow = library:CreateWindow({
- text = "Buy Window"
- })
- mainwindow:AddDropdown(GetAvailableCrystals(), function(choice)
- _G.name = choice
- end)
- mainwindow:AddBox("Amount", function(obj, enter)
- if enter then
- local s, val = pcall(tonumber, obj.Text)
- if s then
- _G.amount = val
- end
- end
- end)
- mainwindow:AddButton("Buy crystals", function()
- if _G.amount and _G.name then
- BuyCrystal(_G.name, _G.amount)
- end
- end)
- local sellwindow = library:CreateWindow({
- text = "Sell Window"
- })
- sellwindow:AddDropdown({"Basic", "Advanced", "Rare", "Epic", "Unique"}, function(choice)
- _G.sr = choice
- end)
- sellwindow:AddButton("Sell items with <= set rarity", function()
- if _G.sr then
- SellAll(_G.sr)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement