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

问题描述 投票:0回答:1

我有一个本地脚本,可以根据他们所在的球队为球员分配球衣。这是脚本:

查看源代码

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

这有效。问题是,其他球员看不到您的衬衫,因为它只是本地的。我不能将此帖子粘贴到服务器端脚本上,因为据我所知,您无法访问服务器端脚本上的字符。我猜对了吗?我如何使所有球员都能看到所有衬衫?谢谢

lua local server-side roblox
1个回答
0
投票
game.Players.PlayerAdded:Connect(function(plr)    

    plr.CharacterAdded:Connect(function(char)
          -- here check the player's team and change the shirt
    end)

end)

尝试这种方式。

© www.soinside.com 2019 - 2024. All rights reserved.