【发布时间】:2019-05-03 08:25:48
【问题描述】:
【问题讨论】:
-
这段代码是正确的。
-
我想制作它,所以当我加入游戏时它只会显示给我的角色
【问题讨论】:
借鉴 Vigus Widdicombe-Gasson 的回答。看起来您在截取代码之前更正了脚本。
Output 窗口中以红色显示的错误告诉您如何找出问题所在。
ServerScriptService.Script:14: ')' Expected (to close '(' at line 3) near <eof>
此错误表示在 ServerScriptService 中,有一个 Script 在第 14 行引发了错误。
这个错误是')' Expected near <eof>。这意味着在某处应该有一个右括号,但脚本在找到它之前就到达了文件的末尾。此外,它告诉我们这个括号的开头位于第 3 行。
因此,您只需在正确的位置添加) 即可解决此问题。您的代码缩进使您很难看到错误在哪里,但它应该出现在您的 end) 语句之一之后。
为了清楚起见,我将在此处重新输入您的代码:
game.Players.PlayerAdded:Connect(function(player)
if player.name == 'MateoGaming_YT' then
player.CharacterAdded:Connect(function(char) -- << this line needed a close parenthesis
-- be careful how you indent here, try to keep everything in the correct tab
local attachment0 = Instance.new("Attachement", char.Head)
local attachment1 = Instance.new("Attachement", char.HumanoidRootPart)
local trail = game.ServerStorage.Trail:Clone()
trail.Parent = char.Head
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
end) -- end player.CharacterAdded
end -- end if
end) -- end game.Players.PlayerAdded
【讨论】:
您做错的只是以错误的顺序获取代码!哦,你需要在末尾添加一个括号)就像这样:
game.Players.PlayerAdded:Connect(function(player)
if player.Name == 'MateoGaming_YT' then
player.CharacterAdded:Connect(function(char)
local trail = game.ServerStorage.Trail:Clone()
trail.Parent = char.Head
--And all the rest of the trail bit
end)
end)
end)
如果您需要更多帮助,请随时提出!
【讨论】: