#How to make replacing instances with different names?
1 messages · Page 1 of 1 (latest)
your specChange function is destroying everything inside the player including some that are probably irrelevant (like backpack)
you are checking if the value's name isn't named Spec
i think you meant to do == rather than ~= ?
@fluid warren
mb i got busy with something
I noticed it was destroying the string value too so I set that, ig I didn't notice everything else because it automatically replicates in the game
that's the main problem I'm getting, I need to be able to find the old file who's name matches what the string value used to be before it changed
just changed it
hold up I was searching in the player instead of the character i'm so dumb
thanks for the help man
thanks i have problems like this all the time
i came here becuase i had a problem and im just helping random people now lol
lmao
wait actually new problem
I set oldSpec outside of the function so it only sets once, if I change it again it'll only search for the original definition
ok so I want to make a kinda replacement system, a player can only have one "spec" at a time, and if they get a new one, it replaces whatever spec they had before
is that "spec" a tool inside the character?
nah its a file
hmm okay
I need to define the spec they had beforehand and destroy it, but idk how to define it and replace the definition if it's already set
is there anything in common that all these specs have
closest thing I can think of is that they all have a script with the same name in them
okay, that works
lemme try that rq
ok weird problem, it searches everything but stops when something doesnt meet the definition
hold on you gotta find the folder with that script inside it and destroy that folder then put the new folder
you used return rather than continue?
InputScript
hmm i think you could use a findfirstchild that would check if any of the character's children have a script called InputScript, but i forgot what it was called
:FindFirstAncestor() i think
try Char:FindFirstAncestor("InputScript")
i mean i dont know the behind of that method
so it could be doing the same thing lol
oh no i think ancestor is something else
it can't index the input script
hold on ill research
oh descendent
i mixed it up wait
yeah we confused descendant with ancestor i think
yeah
it says i have to enable the function though
would it cause any issue if you were to rename the folder to "Spec"
all spec folders
yeah there's some things ServerSide I want to only work with that specific folder
ig that would work yeah
okay one second
local function getSpecFolder(character)
for _, child in character:GetChildren() do
if child:IsA("Folder") and string.sub(child.Name, -4) == "Spec" then
return child
end
end
return nil -- if no spec folder
end
then you can do
local SpecFolder = getSpecFolder()
if SpecFolder then SpecFolder:Destroy() end
@fluid warren
ok hold up so it searches the character for a folder and then checks if it ends in "Spec", if it finds it, it returns the function
yes
wow nice
it returns the child
that seems a lot safer than what i came up with actually
just make sure there is nothing else that ends with spec
Spec, first letter is capitilized
what happened?
it deleted everything in my player's other folders
which is weird because it's only effecting the character
huh
idk man i undid all of it too and it's still doing it
ok mb I forgot to redefine some variables
** You are now Level 10! **
it works fine now, thanks man 💯