Elseif Statement Not Working?

I’m not sure why but the final elseif statement is not being detected it just gets skipped. I’m not sure if I used it in the wrong spot or whats going on with it but I need to fix it.

if map:FindFirstChild("Obby1") then
	roundType = "Obby1"
	map.EndPart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and canWin == true then
	canWin = false
			status.Value = hit.Parent.Name.." has won!"
			
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value + 1
			plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 75
end

end)
elseif map:FindFirstChild(“Spinner1”) then
roundType = “Spinner1”
local Players = game:GetService(“Players”)
local playerInRound = {}
local connections = {}
MultpleWinners = true

	local children = workspace.Ingame:GetChildren()
	for _,  Player in pairs(Players:GetChildren()) do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
			for i = 1,#children do
				print(i)
			table.insert(playerInRound, Player)
			connections[Player.name] = Player.Character.Humanoid.Died:Connect(function()
			table.remove(playerInRound, table.find(playerInRound, Player))
						
				end)
		end	
	
			--Sword1
			
		elseif map:FindFirstChild("Sword1") then
			print("1")
			roundType = "Sword1"
			print(roundType.Value)
	local Players = game:GetService("Players")
	-- Tables
	local playerInRound = {}
	local connections = {}
	
	-- Main Script
	
			local children = workspace.Ingame:GetChildren()
			print("Worked")
	for _,  Player in pairs(Players:GetChildren()) do
		if Player.Character and Player.Character:FindFirstChild('Humanoid') then
					for i = 1,#children do
						print(i)
				map:FindFirstChild("Tool"):Clone().Parent = children[i]
				table.insert(playerInRound, Player)
				connections[Player.name] = Player.Character.Humanoid.Died:Connect(function()
					table.remove(playerInRound, table.find(playerInRound, Player))
					
				end)
			end
		end
	end
end

end

your missing a end) for “map.EndPart.Touched:Connect(function(hit)”

You should format your code better and use functions so that you can read it better. The else if might not be running because of a syntax error.

1 Like