Roblox - 如何查看玩家的团队?
Roblox - How do I check the player's Team?
我从事角色扮演游戏,玩家必须在特定工作中安装散热器。现在我只希望管道工能够安装散热器,因此我在项目放置系统上工作。我目前面临的唯一问题是,即使我在正确的团队中,它仍然无法检测到我是正确的人。
这是使用的相关完整脚本。
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
结束)
您需要检查颜色例如:
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)
我从事角色扮演游戏,玩家必须在特定工作中安装散热器。现在我只希望管道工能够安装散热器,因此我在项目放置系统上工作。我目前面临的唯一问题是,即使我在正确的团队中,它仍然无法检测到我是正确的人。 这是使用的相关完整脚本。
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
结束)
您需要检查颜色例如:
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)