Не работает, рыбу не убирает и деньги не даёт перепиши с нуля этот скрипт local…
- User
Не работает, рыбу не убирает и деньги не даёт перепиши с нуля этот скрипт
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local HttpService = game:GetService("HttpService")
local DataManager = require(script.Parent.DataManager) local FishModule = require(ReplicatedStorage.Modules.FishModule)
local sellPart = workspace:WaitForChild("SellPart") local multiplierValue = sellPart:WaitForChild("Multiplier")
local function sellFish(player) local character = player.Character if not character or not character:FindFirstChild("HumanoidRootPart") then return end
codelocal playerData = player:FindFirstChild("PlayerData") if not playerData then return end local inventoryValue = playerData:FindFirstChild("Inventory") local coinsValue = playerData:FindFirstChild("Coins") if not inventoryValue or not coinsValue then return end local inventory = HttpService:JSONDecode(inventoryValue.Value) local coins = tonumber(coinsValue.Value) local multiplier = multiplierValue.Value local totalValue = 0 local soldFish = {} -- Продаем все рыбы из инвентаря for i = #inventory, 1, -1 do local fishId = inventory[i] local fishData = FishModule[fishId] if fishData then local sellPrice = fishData.Value * multiplier totalValue = totalValue + sellPrice table.insert(soldFish, {id = fishId, price = sellPrice}) table.remove(inventory, i) end end -- Обновляем инвентарь и монеты inventoryValue.Value = HttpService:JSONEncode(inventory) coins = coins + totalValue coinsValue.Value = tostring(coins) -- Сохраняем данные игрока DataManager.SavePlayerData(player) -- Отправляем подтверждение клиенту ReplicatedStorage.Events.FishSold:FireClient(player, soldFish, totalValue) print(player.Name .. " продал рыбу на общую сумму " .. totalValue .. " монет") - Assistant
Вот переписанный скрипт с исправлениями и дополнениями:
lua
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.