How could I make this so it could add two users that had matching/similar users to a table to prevent accidental command execution?

It’s already in a loop that is looping through the arguments. How would I go about adding something in here that could detect if two users had similar usernames to prevent accidental command execution on two users, if the admin only meant to do one?

for a,b in next,Players:GetPlayers() do
					if string.sub(b.Name:lower(),1,#Segment) == lowerSegment then
						table.insert(toReturn,b)
					end
				end
1 Like

I don’t think there’s any need to add them to a table. You should just break the loop once the if statement has been passed

for a,b in next,Players:GetPlayers() do
	if string.sub(b.Name:lower(),1,#Segment) ~= lowerSegment then continue end
	
	-- do stuff
	
	break
end
1 Like

that’s how basic admin essentials does it bc it’s a modulescript returning to another modulescript, also it’s automatically in a loop for the arguments so what would be the best way to tell if two people had similar users the admin tried to execute on both just by using the first few characters

gonna make a new post, resolved for now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.