我查看了许多其他问题及其答案,但似乎仍然无法修复此错误消息。我正在编写一个脚本,允许一个玩家改变另一个玩家的脸。由于新的 ROBLOX 更新,它与 FE 兼容,因此即使错误在服务器脚本中,我也会将本地脚本和服务器脚本放在下面。
本地脚本:
plr = script.Parent.Parent.Parent.NameInput.Text
script.Parent.MouseButton1Click:Connect(function()
script.Parent.RemoteEvent:FireServer(plr)
end)
服务器脚本:
faceid = script.Parent.FaceID.Value
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
script.Parent.PName.Value = plr
local plrname = script.Parent.PName.Value
print (plrname)
game.Players[script.Parent.PName.Value].Character.Face.Texture = faceid
end)
层次结构: 这是我正在创建的 GUI 层次结构的图像
错误消息: 这是当我按下资源管理器中名为“One”的“Test Face”按钮时收到的错误图像。
服务器脚本有点乱,因为我尝试了几种不同的方法来解决此错误,因此如果您认为我可以更改任何内容或添加/删除任何内容,我将不胜感激。但是,目前的主要问题是我在第 4 行遇到的错误。第 7 行也有一个先前的错误,它说“错误的参数 #2 到”?(string expected, got Object)',但我想先解决这个问题。如果试图帮助我的人认为有必要,我们将不胜感激。
提前谢谢你,罗汉
而不是使用,plr
您应该通过使用来获取plr 的名称plr.Name
。这样,您将告诉系统玩家的名称而不是获取对象。
faceid = script.Parent.FaceID.Value
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
script.Parent.PName.Value = plr.Name -- edit was here
local plrname = script.Parent.PName.Value
print (plrname)
game.Players[script.Parent.PName.Value].Character.Face.Texture = faceid
end)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句