i dont focus that much on string manipulation, but I want to make a kick command though when i was testing around with string.sub
it doesnt work for some reason:
game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(message) if message == string.sub(":kick ", 1, 6) then print("lol") end end) end)
im not asking for a script of a entire kick command, but i just want a idea of it
You should definitely use:
string.match(a1, a2)
This will definitely give you the results you need.
Example:
if string.match(message, ":kick ") then print('Someone was kicked') if game.Players:FindFirstChild(message:gsub(":kick ", '')) then game.Players:FindFirstChild(message:gsub(":kick ", '')):Kick() print(game.Players:FindFirstChild(message:gsub(":kick ", '')).Name..' was kicked') end end
Why?
If it does contain that message, then it returns true, if it doesn't- return false.
a1 = string/target
a2 = string to find in target