【发布时间】:2016-06-18 23:10:20
【问题描述】:
在我的名为 MainGameScript 的服务器脚本中,我有这个代码块:
local myRemoteFunction = Instance.new("RemoteFunction")
myRemoteFunction.Parent = game.Workspace
myRemoteFunction.Name = "GetBuildInfo"
game.Players.PlayerAdded:connect(function(player)
print("[MainGameScript] added player")
for i,v in pairs(Regions) do
if (v.Value == 0) then
Regions[i].Value = player.UserId
break
end
end
local success, result = pcall(function() return myRemoteFunction:InvokeClient(player) end)
if success then
print(result)
else
print("Error calling RemoteFunction GetBuildInfo")
end
结束)
我在 game.Workspace 中有一个名为 LocalBuildScript 的 LocalScript,其中包含:
function game.workspace.GetBuildInfo.OnClientInvoke()
print("[GetBuildInfo] will send back local build info")
return "this will be returned to the server caller script"
end
永远不会调用 GetBuildInfo 函数。我在调用函数中添加了一些调试打印行,并且该进程似乎在它使用 pcall 的时候死掉了......这几乎是 Roblox Wiki 中的远程函数客户端调用示例,不知道为什么它不工作并且我希望这里有人有使用 InvokeClient 脚本的经验。
谢谢, 安迪
【问题讨论】:
标签: roblox