So I made a feature where you will type in the name of your tag and the team name, then you will be bring to it. Here I will use a pairs loop to loop through all tags that I made then check if the text you typed in is corrects. If it corrects then you will be bring to that team. The problem here is the loop didn’t loop through every tags but only the first tag it saw. The thing I want here is to fix it so the loop will loop through all the tags, not the first one in it.
local REGIMENT_TITLES = { -- Demo
[1] = "[olla]";
[2] = "[Main]";
[3] = "[Sup]";
[4] = "(Trolla)";
[5] = "{Joe'm}";
[6] = "[Rick]";
[7] = "(Clown)";
[8] = "{Santa}";
[9] = "[Admins]";
}
for i, regTitles in pairs(REGIMENT_TITLES) do
-- If data is empty or incorrect
if regimentTitlesBox.Text == "" or teamNameBox.Text == "" then
regimentTitlesBox.PlaceholderText = "Empty data!"
teamNameBox.PlaceholderText = "Empty data!"
wait(1)
regimentTitlesBox.PlaceholderText = "Type regiment name..."
teamNameBox.PlaceholderText = "Type team name..."
break
elseif regimentTitlesBox.Text ~= sysModule.MainGroupTitle or regimentTitlesBox.Text ~= regTitles then
regimentTitlesBox.Text = ""
regimentTitlesBox.PlaceholderText = "Incorrect regiment name!"
wait(1)
regimentTitlesBox.PlaceholderText = "Type regiment name..."
break
end
-- If all are correct
transferEvent:FindFirstChild("SendTransfer"):FireServer()
transferEvent:FindFirstChild("RecvTransfer").OnClientEvent:Connect(function(plr)
checkForPlayerRegiment(teamNameBox.Text, regimentTitlesBox.Text)
regimentFrame.Visible = false
end)
break
end
The output that I saw then printing out the regTitles (even on the top) is showing “[olla]”
The break there is to stop the statement from running multiple times since it starts to be like that. Any help is appreciated.
Not really, there’s no output about that.
Edit: So I’ve tried to remove the last break method, and now it does looping through the tags but this is too late for a check https://gyazo.com/00c9ce4bd87253085ee133ada20fbe71
2 is the data incorrect statement
1 is the missing data statement
You should just add a check to see if it ran through the remotes the first time then ignore it the other times, of course, the loop won’t run till the end if you have a break happen after the first loop
local isfired = false -- Put this anywhere above in the script
if not isfired then
transferEvent:FindFirstChild("SendTransfer"):FireServer()
isfired = true
transferEvent:FindFirstChild("RecvTransfer").OnClientEvent:Connect(function(plr)
checkForPlayerRegiment(teamNameBox.Text, regimentTitlesBox.Text)
regimentFrame.Visible = false
end)
end
Thank you for your helps and thanks to DevTest_2hd235 for the suggestion. I’ve realized that the value ~= value
didn’t work for me, I tried to put in the not value == value
and it works fine again, don’t really know why but the problem is solved.
Yeah, if you didn’t know you can just put “if not value then” it’s the same as typing “if value == nil” (nil means nothing), you can also do it vice versa, “if value then” is the same as “if value ~= nil”