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

How to find a folder with the same name as a string value?

Asked by 4 years ago
Edited 4 years ago

I'm trying to make a character swap system, something similar to genshin impact but I'm having quite bit of trouble getting a small part through. So there is a local script that changes a stringvalue's value to a different name and then if it has been changed it fires a remoteevent on server side which has to change the player's appearance and everything works until this lines of code:

for i,v in pairs(rs:GetChildren()) do
    if v.Name == cf.Current.Value then
        print(v.Name)
    end
end

you can ignore the print(v.Name) part because its just a way to debug.

The issue there is that it doesn't find any folders with the same name as the value in the stringvalue.

for i,v in pairs(rs:GetChildren()) do
    if v.Name ~= cf.Current.Value then
        print(v.Name)
    end
end

^ This version of the code makes it so everything in "rs" get printed even if it has the same name as the value in the stringvalue so i think the issue is in the value itself but i cannot find why

0
Is the name of `v` the same as `cf.Current.Value`? Maybe one of the names has a capital letter and the other doesn't. Maybe, since you said you're handling the changing of the value on the client, filtering enabled is getting in the way. We can't tell without more code/context Gey4Jesus69 2705 — 4y
2
The problem is that you're changing the value on the client and comparing that same value on the server. R_alatch 394 — 4y
0
@R_alatch this was actually the issue thanks if you put it as an answer i can accept it as an asnwer richboifexekappa 89 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I can help you with this.

Ok, first you want to get the location of the folder. For this example, the location is in the workspace.

game.Workspace

Then get the String Value's value. Then getting the folder would be as simple as this.

local string = -- the string value

local folder = game.Workspace[string]

Now "folder" is the folder you are trying to get.

Hope this helps!

Ad
Log in to vote
0
Answered by 4 years ago

"The problem is that you're changing the value on the client and comparing that same value on the server." ~ R_alatch

he won't put it as an answer so i'm doing it myself

Answer this question