【问题标题】:Roblox - How do I check the player's Team?Roblox - 我如何查看玩家的队伍?
【发布时间】:2021-01-13 03:45:10
【问题描述】:

我正在开发一款角色扮演游戏,玩家必须在特定工作中安装散热器。现在我只希望管道工能够安装散热器,因此我在一个物品放置系统上工作。我目前面临的唯一问题是,即使我在正确的团队中,它仍然无法检测到我是正确的人。 这是使用的相关完整脚本。

script.Parent.Event.OnServerEvent:connect(function(player)
if player.Team == game.Teams.Haustechniker then
    local backpack = player:WaitForChild("Backpack")
    local character = player.Character or player.CharacterAdded:Wait()
    local function purgeLaunchers(container)
        for _, item in pairs(container:GetChildren()) do
            if item:IsA("Tool") and item.Name:match("Abdeckvlies") then
                item:Destroy()
                script.Parent.Part.Transparency = 0
                script.Parent.Event:Destroy()
                script.Parent.Text:Destroy()
                script.Parent.Range:Destroy()
            
            end
        end
    end
    purgeLaunchers(backpack)
    purgeLaunchers(character)
end

结束)

【问题讨论】:

    标签: lua roblox


    【解决方案1】:

    你需要检查颜色例如:

    local function checkTeam(player)
        if player.TeamColor ~= nil then
            if player.TeamColor == 'Red' then
                return 'Red'
            elseif player.TeamColor == 'Orange' then
                return 'Orange'
            end
        else
            return false
        end
        return nil
    end
    
    game.Players.PlayerAdded:Connect(function(player)
        if not checkTeam(player) then return end
        if checkTeam(player) == 'Red' then
            print(player.Name .. ' is in the red team')
        end
    end)
    

    【讨论】:

      猜你喜欢
      • 2019-06-26
      • 1970-01-01
      • 2018-12-16
      • 2022-10-05
      • 2016-11-27
      • 2021-12-28
      • 2021-04-11
      • 2021-06-22
      • 2021-11-02
      相关资源
      最近更新 更多