You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
i want the below to not return nil
string.match(“Text”,“The Text”)
What is the issue? Include screenshots / videos if possible!
the issue is that i am not very experienced in string manipulation
but it seems like i can not avoid it this time in the script im writing
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i looked on google but the solution gave was something similar to this
string.match(“i have a bag”, “bag”) = bag
what i want is this but that returns nil
string.match(“i have a bag”, “the bag”)
local groupService = game:GetService'GroupService'
local UserId = 1556794251
local groups = groupService:GetGroupsAsync(UserId)
local groupsInfo = {}
for _, groupInfo in pairs(groups) do
table.insert(groupsInfo, (groupInfo.Rank == 255) and groupInfo.Name or nil)
table.insert(groupsInfo, (groupInfo.Rank == 255) and groupInfo.Id or nil)
end
local replicatedStorage = game:GetService'ReplicatedStorage'
local remoteEvent = replicatedStorage.RemoteEvent
remoteEvent.OnServerEvent:Connect(function(player, text)
for i, v in pairs(groupsInfo) do
local match = tostring(v):match(text)
print(match)--this is the part that went wrong where it didnt match anything
--because the computer is trying to match "The Royal Family" to get string "Royal Family"
--and it didnt find anything because the computer is thinking the pattern as a whole
--where as i only am trying to use a part of it not the entire thing
--but i dont know how to delete "The" without effecting the text on the player's screen
if match ~= nil then
local groupId = groupsInfo[i + 1]
print(groupId)
local rank = player:GetRankInGroup(groupId)
print(rank)
end
end
end)