如何使本地分配的服装对所有玩家可见?

我有一个本地脚本,根据玩家所在的团队为其分配衬衫。以下是脚本:

01  local player = game.Players.LocalPlayer
02
03  local char = player.Character or player.CharacterAdded:Wait()
04
05  local shirt
06
07  if player.Team == game.Teams["Red Team"] then
08  shirt = "http://www.roblox.com/asset?id=73022512"
09  elseif player.Team == game.Teams["Blue Team"] then
10  shirt =  "rbxassetid://184244692"
11  elseif player.Team == game.Teams["Yellow Team"] then
12  shirt = "http://www.roblox.com/asset/?id=1210716332"
13  elseif player.Team == game.Teams["Green Team"] then
14  shirt = "http://www.roblox.com/asset/?id=13997666"
15  end
16
17  if char:FindFirstChild("Shirt") then
18  char.Shirt.ShirtTemplate = shirt
19  else
20  local newShirt = Instance.new("Shirt")
21  newShirt.Parent = char
22  newShirt.ShirtTemplate = shirt
23  end

这个可以工作。问题是,其他玩家看不到你的衬衫,因为它是本地的。我无法将此帖子粘贴到服务器端脚本上,因为据我所知,在服务器端脚本上无法访问角色。我对吗?如何使所有衬衫对所有玩家可见?谢谢!

点赞
用户12839543
用户12839543
game.Players.PlayerAdded:Connect(function(plr)

    plr.CharacterAdded:Connect(function(char)
          -- 在这里检查玩家的队伍并更换衬衫
    end)

end)

尝试这种方式。

2020-02-04 14:20:01