Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is the 'elseif' failing in the script?

This script seems to jump literally over everything and prints the last text "No Armor." I have no idea why it is jumping over. I set the value for Armor to be '6' and still jumps over. Can anyone explain why this is the case?

local arm = game.Players.LocalPlayer.Attributes.Armor.Value
local mesh2 = game.ReplicatedStorage.Armors["2"]:GetChildren()
local mesh3 = game.ReplicatedStorage.Armors["3"]:GetChildren()
local mesh4 = game.ReplicatedStorage.Armors["4"]:GetChildren()
local mesh5 = game.ReplicatedStorage.Armors["5"]:GetChildren()
local mesh6 = game.ReplicatedStorage.Armors["6"]:GetChildren()
local mesh7 = game.ReplicatedStorage.Armors["7"]:GetChildren()	
local mesh8 = game.ReplicatedStorage.Armors["8"]:GetChildren()
local mesh9 = game.ReplicatedStorage.Armors["9"]:GetChildren()
local mesh10 = game.ReplicatedStorage.Armors["10"]:GetChildren()
local mesh11 = game.ReplicatedStorage.Armors["11"]:GetChildren()
local mesh12 = game.ReplicatedStorage.Armors["12"]:GetChildren()
			
print(arm)		
			
if arm == 2 then
	for i=1, #mesh2 do
		mesh2[i]:Clone().Parent = player.Character
		print('Meshed 2')
	end
elseif arm == 3 then
	for i=1, #mesh3 do
		mesh3[i]:Clone().Parent = player.Character
		print('Meshed 3')
	end
elseif arm == 4 then
	for i=1, #mesh4 do
		mesh4[i]:Clone().Parent = player.Character
		print('Meshed 4')
	end
elseif arm == 5 then
	for i=1, #mesh5 do
		mesh5[i]:Clone().Parent = player.Character
		print('Meshed 5')
	end
elseif arm == 6 then
	for i=1, #mesh6 do
		mesh6[i]:Clone().Parent = player.Character
		print('Meshed 6')
	end
elseif arm == 7 then
	for i=1, #mesh7 do
		mesh7[i]:Clone().Parent = player.Character
		print('Meshed 7')
	end
elseif arm == 8 then
	for i=1, #mesh8 do
		mesh8[i]:Clone().Parent = player.Character
		print('Meshed 8')
	end
elseif arm == 9 then
	for i=1, #mesh9 do
		mesh9[i]:Clone().Parent = player.Character
		print('Meshed 9')
	end
elseif arm == 10 then
	for i=1, #mesh10 do
		mesh10[i]:Clone().Parent = player.Character
		print('Meshed 10')
	end
elseif arm == 11 then
	for i=1, #mesh11 do
		mesh11[i]:Clone().Parent = player.Character
		print('Meshed 11')
	end
elseif arm == 12 then								
	for i=1, #mesh12 do
		mesh12[i]:Clone().Parent = player.Character
		print('Meshed 12')
	end	
else
	print('No Armor')	
end
		

2 answers

Is this the whole script? Does it go on/off on a given action or no? I mean this script seems to go off before the game is even fully loaded. Maybe add a Waitforwhatever? Idk though, it's my best guess.

1 comment

0

It's part of a GUI that if you click on it, it skips various things. A Skip button, essentially. So, the game is well loaded.

Aren't calling the function at all..

In front of all the coding you did add this line

script.Parent.MouseButton1Click:connect() --only if script is in button
--code you did goes in here
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.