hello,
im trying to create a script that, once it's cloned into a specific folder, runs it's script.
currently, the game creates a folder (folder A) within an already existing folder (folder B) in ServerStorage, then clones a script into folder A. the script starts with:
local ServerStorage = game:GetService("ServerStorage") if script.Parent.Parent.Parent == ServerStorage then --script here end
which, is not only extremely embarrassing to post and grossly inefficient, but also doesn't work. surprise surprise.
im still very new to this. i am looking up tutorials and checking the API when i can but i cant find anything that could help me in this regard. whats worse is that this has actually worked before - when cloning a simple object into the workspace that had a script attached that checked if it was in the workspace, then fired its script. but its not working for this more complex script.
i dont know what to do. im sure there are better ways of doing what i want to, and even of doing it in this manner, but i just dont know. any feedback or ideas would be fantastic.
thank you in advance.
PS: im sorry you had to read that script abomination
If you keep the script inside of the replicated storage service it will not run until cloned, and parented somewhere else.
You shouldn't be looking into API
's to find an answer to this query of yours.
Anyways, try the code below.
script.Parent.Parent:GetPropertyChangedSignal('Parent'):Connect(function() if script.Parent.Parent.Parent == game:GetService('ServerStorage') then --script here end
I'm not sure that Parent
is a proper argument for the GetPropertyChangedSignal
, as the Parent
property isn't a StringValue
(per say).
Please let me know is the code works. If it doesn't then I'd be happy to provide an alternative solution to your issue.