roblox studio 'end' 预计(关闭 'function' 第 1 行)在 <eof> 附近
roblox studio 'end' expected (to close 'function' at line 1) near <eof>
我尝试编写一些代码来在有人聊天时在工作区内创建一个名为 Console 的文件夹 "Console on" 并在有人说 "Console off" 时删除它但是当我 运行 它在 public 游戏(因为在 roblox studio 的测试模式下没有聊天)我得到了标题错误,在阅读了几篇帖子后都没有答案。
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif
msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
如果您将代码缩进得更一致,将更容易看出语法错误在哪里:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
更清楚:
game.Players.PlayerAdded:Connect(
function(plr)
plr.Chatted:Connect(
function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
您需要在最后添加另一个 end)
以关闭 game.Players.PlayerAdded:Connect(function(plr)
:
game.Players.PlayerAdded:Connect(
function(plr)
plr.Chatted:Connect(
function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
end)
我尝试编写一些代码来在有人聊天时在工作区内创建一个名为 Console 的文件夹 "Console on" 并在有人说 "Console off" 时删除它但是当我 运行 它在 public 游戏(因为在 roblox studio 的测试模式下没有聊天)我得到了标题错误,在阅读了几篇帖子后都没有答案。
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif
msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
如果您将代码缩进得更一致,将更容易看出语法错误在哪里:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
更清楚:
game.Players.PlayerAdded:Connect(
function(plr)
plr.Chatted:Connect(
function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
您需要在最后添加另一个 end)
以关闭 game.Players.PlayerAdded:Connect(function(plr)
:
game.Players.PlayerAdded:Connect(
function(plr)
plr.Chatted:Connect(
function(msg)
print("Connected")
if msg == "Console on" then
console = Instance.new("Folder",workspace)
console.name = "Console"
print("Console Made")
elseif msg == "Console off" then
print("Console Destroyed")
console:Destroy()
end
end)
end)