Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-30b-a3b· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

Tenha em mente que o dummy é R6, e que o que eu quero é um sistema individual pra cada…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    Tenha em mente que o dummy é R6, e que o que eu quero é um sistema individual pra cada um, pois lidaremos com multiplos tipos de npcs no futuro, o gear fica filho direto do character, ou tem uma forma melhor de fazer esse sistema, por exemplo, deixando a ferramenta em alguma pasta sepaarada

  2. Qwen Assistant

    Aqui está uma versão otimizada do sistema com as melhorias solicitadas:

    Estrutura do Sistema (Organização)

    ServerScriptService/
    ├── NPCManager.lua
    ├── NPCBase.lua
    └── Tools/
        ├── Tool1.lua
        └── Tool2.lua
    
    LocalScripts/
    └── NPCToolHandler.lua
    

    1. Script Principal (ServerScriptService/NPCManager.lua)

    -- Servidor: Gerenciamento dos NPCs
    local ServerScriptService = game:GetService("ServerScriptService")
    local Players = game:GetService("Players")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    
    local NPCManager = {}
    local NPCs = {}
    
    -- Criação de NPC base
    local function createNPC(npcType, position)
        local npcModel = Instance.new("Model")
        npcModel.Name = "NPC_" .. npcType
        npcModel.PrimaryPart = Instance.new("Part")
        npcModel.PrimaryPart.Size = Vector3.new(2, 2, 1)
        npcModel.PrimaryPart.Anchored = false
        npcModel.PrimaryPart.CanCollide = true
        npcModel.PrimaryPart.Material = Enum.Material.Plastic
        npcModel.PrimaryPart.Position = position
        npcModel.PrimaryPart.Parent = workspace
        
        -- Criação de pasta de equipamentos
        local gearFolder = Instance.new("Folder")
        gearFolder.Name = "Gear"
        gearFolder.Parent = npcModel
        
        -- Criação do humanoide
        local humanoid = Instance.new("Humanoid")
        humanoid.Name = "Humanoid"
        humanoid.Parent = npcModel
        
        -- Criação do root part
        local rootPart = Instance.new("Part")
        rootPart.Name = "HumanoidRootPart"
        rootPart.Size = Vector3.new(2, 1, 1)
        rootPart.Anchored = false
        rootPart.CanCollide = true
        rootPart.Material = Enum.Material.Plastic
        rootPart.Position = position + Vector3.new(0, 2, 0)
        rootPart.Parent = npcModel
        
        -- Configurações do humanoide
        humanoid.WalkSpeed = 16
        humanoid.MaxHealth = 100
        humanoid.Health = 100
        humanoid.RootPart = rootPart
        
        -- Carrega a ferramenta específica
        local tool = ReplicatedStorage.Tools:FindFirstChild(npcType)
        if tool then
            local toolClone = tool:Clone()
            toolClone.Parent = gearFolder
        end
        
        -- Adiciona ao array
        NPCs[npcModel] = {
            model = npcModel,
            humanoid = humanoid,
            gear = gearFolder
        }
        
        return npcModel
    end
    
    -- Seguir jogador
    local function followPlayer(npcData, player)
        local humanoid = npcData.humanoid
        local rootPart = humanoid.RootPart
        
        while true do
            if not player or not player.Character then break end
            local playerRoot = player.Character:FindFirstChild("HumanoidRootPart")
            
            if playerRoot then
                local distance = (rootPart.Position - playerRoot.Position).Magnitude
                if distance < 20 then
                    humanoid:MoveTo(playerRoot.Position)
                else
                    humanoid:MoveTo(rootPart.Position)
                end
            end
            
            wait(0.1)
        end
    end
    
    -- Evento de player adicionado
    Players.PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character)
            local spawnPosition = Vector3.new(math.random(-50, 50), 5, math.random(-50, 50))
            local npcModel = createNPC("Tool1", spawnPosition)
            
            -- Inicia o seguimento
            followPlayer(NPCs[npcModel], player)
        end)
    end)
    
    -- Limpeza de NPCs
    game:GetService("RunService").Heartbeat:Connect(function()
        for npcModel, data in pairs(NPCs) do
            if not npcModel or not npcModel.Parent then
                data.gear:Destroy()
                data.model:Destroy()
                NPCs[npcModel] = nil
            end
        end
    end)
    
    return NPCManager
    

    2. Ferramentas (ReplicatedStorage/Tools/Tool1.lua)

    -- Ferramenta básica para NPC
    local tool = Instance.new("Tool")
    tool.Name = "Tool1"
    tool.RequiresHandle = true
    
    local handle = Instance.new("Part")
    handle.Name = "Handle"
    handle.Size = Vector3.new(1, 1, 1)
    handle.Material = Enum.Material.Neon
    handle.Color = Color3.fromRGB(0, 255, 0)
    handle.Anchored = true
    handle.Parent = tool
    
    local mesh = Instance.new("BlockMesh")
    mesh.Parent = handle
    mesh.Scale = Vector3.new(1, 1, 1)
    
    tool.Parent = ReplicatedStorage.Tools
    

    3. Script de Controle (LocalScript/NPCToolHandler.lua)

    -- Cliente: Controle da ferramenta do NPC
    local Players = game:GetService("Players")
    local player = Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()
    
    local function onToolUsed(tool)
        print("Ferramenta usada: " .. tool.Name)
        -- Adicione lógica de uso aqui
    end
    
    -- Verifica se há ferramentas no NPC
    local function checkNPCTools()
        local npc = character:FindFirstChild("NPC_")
        if npc then
            local gearFolder = npc:FindFirstChild("Gear")
            if gearFolder then
                for _, tool in ipairs(gearFolder:GetChildren()) do
                    if tool:IsA("Tool") then
                        tool.Equipped:Connect(function()
                            onToolUsed(tool)
                        end)
                    end
                end
            end
        end
    end
    
    -- Monitora mudanças no personagem
    character:WaitForChild("HumanoidRootPart")
    checkNPCTools()
    
    -- Atualiza quando o personagem muda
    player.CharacterAdded:Connect(function(newCharacter)
        newCharacter.HumanoidRootPart.Changed:Connect(checkNPCTools)
        checkNPCTools()
    end)
    

    Melhorias Principais:

    1. Organização por Pasta:

      • Cada NPC tem uma pasta "Gear" com suas ferramentas
      • Ferramentas são armazenadas em ReplicatedStorage/Tools/
    2. Sistema Modular:

      • Cada tipo de NPC pode ter sua própria ferramenta
      • Adição de novos tipos é simples (basta criar nova ferramenta em Tools/)
    3. R6 Compatibility:

      • Usa HumanoidRootPart corretamente para NPCs R6
      • Não depende de partes específicas como "Torso"
    4. Escalabilidade:

      • Pode ser expandido para diferentes tipos de NPCs
      • Facilidade de adicionar novas funcionalidades
    5. Segurança:

      • Ferramentas são clonadas no lado do servidor
      • Controle de uso é feito no cliente

    Como Usar:

    1. Crie pastas e scripts conforme a estrutura
    2. Adicione novas ferramentas em ReplicatedStorage/Tools/
    3. Modifique NPCManager.lua para criar diferentes tipos de NPCs
    4. O sistema automaticamente carrega a ferramenta correta para cada NPC

    Este sistema permite que você crie múltiplos tipos de NPCs com diferentes ferramentas, mantendo a organização e escalabilidade para futuras expansões.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.