How to compare a object name to a string?

Im looking to compare a group of objects (by name) if they start with something. I have a system of player stats that I need to be reset each round. So far iv separated this by having it have “Round” in the name (e.g. “RoundCoins”). Is there any way to do something like this?

for i,v in pairs plr.stats:GetChildren() do
     if v.Name == ("Round" --here I want a code that tells the script the rest of the string can be anything
     ) then
           v.Value = 0
     end
end

I know this might not be a perfect code but it should provide an example of what I need, Iv checked other articles and searched for it but I cant find anything on if such a code exists.

You could do something like this:

if v.Name:match("Round") then

or

if v.Name:find("Round") then

Reference: string.

1 Like