【发布时间】:2020-07-30 01:45:22
【问题描述】:
我一直在尝试制作 Roblox 剑斗游戏(我的第一个 roblox 游戏)。 我在我的代码中发现了一些语法问题,但修复它们并没有解决这个问题。我一直在检查我的代码,但似乎没有任何效果。 这是第 15 到第 83 行代码,因为 cmets 告诉我问题出在 for 循环之前(第 15 行之前只是变量)
--Game Loop
while true do
Status.Value = "Waiting for enough players"
repeat wait(1) until game.Players.NumPlayers >= 2
Status.Value = "Intermission"
wait(10)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) -- Add each player into plrs table
end
end
wait(2)
local AvailableMaps = MapsFolder:GetChildren()
local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
Status.Value = ChosenMap.Name.." Chosen"
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace
--Teleport players to the map
local SpawnPoints = ClonedMap:FindChild("SpawnPoints")
if not SpawnPoints then
print("Spawnpoints not found!")
end
local AvailableSpawnPoints = SpawnPoints:GetChildren
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
-- Teleport them
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
table.remove(AvailableSpawnPoints,1)
-- Give them a Sword
local Sword = ServerStorage.Sword:Clone()
Sword.Parent = player.Backpack
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
-- There is no character
if not player then
table.remove(plrs,i)
end
end
end
end
这是错误: 19:30:03.021 - ServerScriptService.Main 脚本:56: 预期 '(', '{' 或 , 得到 'for' 帮助我的游戏玩家
【问题讨论】:
-
您至少拥有
local.Sword并想要local Sword。但是,这并不能解决您在帖子中包含的错误;该错误在其他地方。指出哪一行类似于 56 会很有帮助。 -
如果解释器期望一件事并得到另一件事,那么错误必须在它检测到错误之前的某个时间点。 IOW,这个
for循环可能没有任何问题。看看之前的陈述。