Reputation: 1
I have been trying to make a Roblox sword fight game (my first roblox game). I found some syntax problems in my code but fixing them didn't fix this issue. I have been going over my code and nothing really seems to work. Here's the 15th to the 83rd line of code becuase the comments have told me the problem is before the for loop (Before the 15th line are just variables)
--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
Here's the error: 19:30:03.021 - ServerScriptService.Main Script:56: Expected '(', '{' or , got 'for' Help me out fellow gamers
Upvotes: 0
Views: 67
Reputation: 7188
@luther's comment is absolutely right. The line right above the for loop has a syntax error. SpawnPoints:GetChildren
is a function call, and you forgot to add the parentheses.
local AvailableSpawnPoints = SpawnPoints:GetChildren()
Upvotes: 1