Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

String match not finding player?

Asked by
Cuvette 246 Moderation Voter
7 years ago

So I've used the string match off the wiki to find the name of the player in a string and if it finds it then it makes part of the UI non visible. I've printed out the string and it gives me the list of players (The _G.group2members one)

But for some reason, match is not making the UI non visible for those certain players.

Any help would be appreciated! Thanks.

if _G.group2members.match(player, "p%w+") then
        script.Parent.Template1.Add.Visible = false;
end

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Whatever you are doing is completely confusing, and is not valid. Here is some code (this is what I think you are trying to do):

local player = game.Players.LocalPlayer
if string.match(_G.group2members,"//" ..player.Name.. "//") then -- if the player exists
    script.Parent.Template1.Add.Visible = false
end

Make sure to separate all player names with symbol(s) or something else (e.g, //) so that you can find them accurately.

This code would only work in a LocalScript, because of LocalPlayer, but you could swap that out script.Parent.Parent.Parent ... until you get to the player.


Hope I helped!

~TDP

0
I'm not storing the player names in a table, they're all stored in a string which is why i'm trying to find a function that allows me to find a specific word in a string. Cuvette 246 — 7y
0
Finished edits. TheDeadlyPanther 2460 — 7y
0
Had to make a few modifications as you stated but all is working. Thanks a ton! Cuvette 246 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago

Not sure if this will help, but try making line 2 this.

script.Parent.Template1.Visible = false

or try this

script.Parent.Template1.Add.Visible = false

Answer this question