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

Is it possible to kick a player from your game if their name contains a set word?

So if a player had 'Xx' in there name, anywhere in there name, they'd get kicked when'd they try to join the game. Is this possible or not?

1 answer

✓ Accepted answer

Yes. Not sure of this purpose though... Kind of discrimination...

function check(p)
	local maxCombo = string.len(p.Name)  - 1 -- How many possible combinations where 'Xx' could be
	local i = 0 -- Current combo
	while true do -- A loop, to go through all combos
		if i == maxCombo then -- Searched all possible combinations, stop trying
			return false
		end
		local current = string.sub(p.Name, i + 1, i + 3)  -- Grab combo that we are checking
		if string.lower(current) == "xx" then -- If our current combo matches, stop checking, return positive
			return true
		end
		i = i + 1 -- Move to the next combo
	end
end

check(game.Players.XxNamexX) -- > true
check(game.Players.H4X0MSYT) -- > false

2 comments

0

Thank you, much appreciated. Also, Xx was just the first example that popped into my head. I was just planning on using this to kick people who have sort clan names. Such as EXAMPLE_Doggo, so on.. But, once again thank you

0

Would string.contains() or string.find("Hello my friend":lower(), "hello") not be a much simpler job than rolling-your-own string search? A good string search is pretty hard to write.

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