Оптимизируй этот скрипт: local Seed = Random.new(tick()) local function…
- User
Оптимизируй этот скрипт: local Seed = Random.new(tick())
local function PickItem(RarityList: {[string]: number}): string local Num = Seed:NextNumber(0, 100) local Int = 0 for Item, Chance in pairs(jData) do Int += Chance if Num <= Int then return Item end end endпод этот скрипт: local bfolder = workspace.Bottles local rs = game:GetService("ReplicatedStorage") local jFolder = rs:FindFirstChild("Jobs"):FindFirstChild("BottleWork") local jData = { ["Бутылка"] = {0.3, price = 1}, ["Пепси"] = {0.2, price = 2}, ["Черноголовка"] = {0.1, price = 3}, ["Ягуар"] = {0.1, price = 5}, ["Лимонад"] = {0.15, price = 2}, ["Квас"] = {0.1, price = 1}, ["Белый медведь"] = {0.05, price = 10}, ["Пять озер"] = {0.02, price = 8}, ["Тархун"] = {0.02, price = 4}, ["Добрый Кола"] = {0.05, price = 2}, }
for _,b in pairs(bfolder:GetChildren()) do if b.Name == "Bottle" then local Seed = Random.new(tick())
local function PickItem(RarityList: {[string]: number}): string local Num = Seed:NextNumber(0, 100) local Int = 0 for Item, Chance in pairs(jData) do Int += Chance if Num <= Int then return Item end end end local ChosenItem = PickItem(Items) print(ChosenItem) local randomIndex = math.random(1, #jData) b:FindFirstChild("BName").Value = jData[randomIndex] b.Color = jFolder:FindFirstChild(jData[randomIndex]).Handle.Color endend
for _,v in pairs(bfolder:GetChildren()) do if v.Name == "Bottle" then local cdetector = v:FindFirstChild("ClickDetector") cdetector.MouseClick:Connect(function(plr) if v.Transparency ~= 1 then local bName = v:FindFirstChild("BName") local newBottle = jFolder:FindFirstChild(bName.Value):Clone() newBottle.Parent = plr.Backpack v.Transparency = 1 wait(60) local randomIndex = math.random(1, #jData) bName.Value = jData[randomIndex] v.Color = jFolder:FindFirstChild(jData[randomIndex]).Handle.Color v.Transparency = 0 end end) end end
- Assistant
local bfolder = workspace.Bottles local rs = game:GetService("ReplicatedStorage") local jFolder = rs:FindFirstChild("Jobs"):FindFirstChild("BottleWork")
-- Create a separate function for picking a random item from the list local function PickItem() local Seed = Random.new(tick()) local Num = Seed:NextNumber(0, 100) local Int = 0 for Item, Chance in pairs(jData) do Int += Chance[1] if Num <= Int then return Item, Chance[2] -- Return both the item name and its price end end end
-- Loop through each bottle and set its properties for _, b in pairs(bfolder:GetChildren()) do if b.Name == "Bottle" then local ChosenItem, Price = PickItem() b:FindFirstChild("BName").Value = ChosenItem b.Color = jFolder:FindFirstChild(ChosenItem).Handle.Color b.Price.Value = Price -- Set the price using a Value object end end
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.