【发布时间】:2021-09-10 18:59:24
【问题描述】:
所以我试图根据玩家所在的团队为他们提供不同的武器。我试图通过创建一个实例字符串值并将其添加到一个文件夹中,该文件夹是 ReplicatedStorage 中播放器的名称,但它只在播放器端更新,而不是在服务器端更新。我试图通过在 ReplicatedStorage 中创建一个脚本并调用名为 handleTeams 的函数来解决此问题,但我总是收到错误消息,指出 handleTeams 不是脚本的子级。
LocalScript (LocalScript) (Players > Player1 > PlayerGui > InsertedObjects > team > Russia)
local p = script.Parent.Parent.Parent.Parent.Parent.Name
script.Parent.MouseButton1Click:Connect(function()
game.Players[p].TeamColor = BrickColor.new("Really blue")
game.Workspace[p].Humanoid.Health = 0
script.Parent.Parent.Parent.Enabled = false
local Player = Instance.new("Folder")
local GameTag = Instance.new("StringValue")
GameTag.Value = "USA"
GameTag.Name = "TeamName"
Player.Name = game.Players:FindFirstChild(p).Name
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.ReplicatedStorage.Script(Player, GameTag)
end)
TeamGear(脚本)(工作区 > TeamGear)
function onSpawned(plr)
if script.Parent.Parent.ReplicatedStorage.Teams[plr.Name].TeamName == "Russia" then
local tools = script.Parent.Parent.Teams.Russia:GetChildren()
for _,c in pairs(tools) do
c:Clone().Parent = plr.Backpack
end
end
if script.Parent.Parent.ReplicatedStorage.Teams[plr.Name].TeamName == "USA" then
local tools = script.Parent.Parent.Teams.USA:GetChildren()
for _,c in pairs(tools) do
c:Clone().Parent = plr.Backpack
end
end
end
脚本(脚本)(ReplicatedStorage > 脚本)
function handleTeams(player, tag)
player.Parent = script.Parent.Teams
tag.Parent = player
end
【问题讨论】: