Lua 错误的参数#3到';价值';(需要字符串,获取对象)-如何修复此问题?
我已经查看了许多其他问题及其答案,但我似乎仍然无法修复此错误消息。我正在写一个脚本,允许一个玩家改变另一个玩家的脸。由于新的ROBLOX更新,它是FE兼容的,因此我将把本地脚本和服务器脚本放在下面,即使错误在服务器脚本中 本地脚本:Lua 错误的参数#3到';价值';(需要字符串,获取对象)-如何修复此问题?,lua,scripting,roblox,Lua,Scripting,Roblox,我已经查看了许多其他问题及其答案,但我似乎仍然无法修复此错误消息。我正在写一个脚本,允许一个玩家改变另一个玩家的脸。由于新的ROBLOX更新,它是FE兼容的,因此我将把本地脚本和服务器脚本放在下面,即使错误在服务器脚本中 本地脚本: plr = script.Parent.Parent.Parent.NameInput.Text script.Parent.MouseButton1Click:Connect(function() script.Parent.RemoteEvent:Fi
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)
服务器脚本:
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)
层次结构:
错误消息:
服务器脚本有点混乱,因为我尝试了几种不同的方法来避免这个错误,所以如果您认为我可以更改任何内容或添加/删除任何内容,我将非常感谢您的反馈。然而,目前的主要问题是我在第4行遇到的错误。第7行上还有一个错误,它说'bad argument#2 to'?'(应该是字符串,get Object'),但我想先解决这个问题。如果试图帮助我的人认为有必要,我们将非常感谢他们对脚本的帮助
提前谢谢大家,,
Rohan而不是使用,
plr
您应该通过使用plr.name
来获取plr的名称。这样,您将告诉系统玩家的名称,而不是获取对象
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)