I’m making a script where if you click a button, it will clone a folder from replicated storage and move it to workspace.
While the map is being cloned and moved, none of the scripts seem to work.
E.g: In the map, you are supposed to hit a part and be teleported. While it was working when I was building the map, it isn’t when it is cloned and moved
If you could help me that would be great! I can provide and scripts/screenshots/videos.
Hello, am i not sure if i got you or not, But i think you want something like this?
I tried the thing you said and yes when the script is in the ReplicatedStorage then it is moved to somewhere else where it can work, it works and prints, So i dont know what is the problem
But i suggest adding to every script the next function
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
print("Parent was changed")
-- Your code
end)
Small edit
In the code, The parent which is being changed should be the Folder which is cloned, i mean if this script parent is a folder inside that folder then you will change
From
Hello thanks for your reply!
I tried out your code and it doesn’t work.
If you’re a bit confused on what I’m trying to achieve I’ll put it here and try and see if I can try and explain it as simple as possible
When you click a button, it will clone and move a map from replicated storage into workspace
While the map correctly clones and is moved, everything with a script doesn’t work
This includes some scripts with RemoteEvents, localscripts and server scripts
When the Folder with the map and scripts is originally in Workspace (without it being cloned and moved), it works perfectly as normal.
I’m also confused as to why it’s not working because it is an exact 1:1 replica of how it would’ve been if it wasn’t cloned and moved
Okay so, you are cloning a map with scripts inside of it? if that’s the case, usually adding a cloned script or changing a parent propretie of a script will not make it work. I recommend use a script in server script service that detects when the map got cloned and then have a folder inside of it with the scripts set “disable = true”, that the map have inside. Then clone the scripts and move them to each part that needs a script of the new map and then “disable = false” each after moving each script.
Hello! Thanks for your reply!
Unfortunately your solution didn’t work.
Every time the map is cloned and moved, the scripts are also cloned and moved into their proper areas. The code still doesn’t work however.
Add a new “Script” in the “ServerScriptService” and add a “Script” with “Disable = true” inside of it like this:
Now Paste this code in the “Script” (ServerScriptService script one) that is not “Disabled”:
local Script = script:WaitForChild("ScriptCloning")
local Workspace = game:GetService("Workspace")
function MakingAPart()
local Part = Instance.new("Part", Workspace)
Part.Position = Vector3.new(-34.75, 0.5, 8.25)
local NewScript = Script:Clone()
NewScript.Parent = Part
NewScript.Disabled = false
end
wait(5)
MakingAPart()
Now paste this code inside the “ScriptCloning” that is “Disabled”:
local Part = script.Parent
local MouseClick = Instance.new("ClickDetector", Part)
print("Starting")
MouseClick.MouseClick:Connect(function()
print("Working")
end)
Test this code, you can change the “Part”position so you can test it better.
Do exaclty the same but with your scripts, create a script in server script service, do a function when the map got clone, add the scripts you need for the map inside the script or in a folder in server storage (its important to Disable ever script inside the ServerScriptService script one), then do this:
local NewScript = (The script you want to get move to the new map):Clone()
NewScript.Parent = (The part that works with the scripts)
NewScript.Disabled = false ---> This is really importatn, Disable needs to be at last because when we make the script Disable = false the script will run in that moment.
This is an example about how you can implement this in your game, try testing this idea in your game.
actually, if you’re changing the parent of the map on the client side, then it won’t run any server scripts that are inside the map. after I tested, it seems that if you change the parent of the map on the server side then the script should start running
ok so the button that actually clones the map and changes the parent is actually using a local script
however, you’re saying that if I use a server script instead to clone the map and change the parent it will work?
if so I can easily use a RemoteEvent to communicate between the local and server-side script
I’ll test it out in the morning and see if it works!
Thanks for both of your help @Bonusizawesome@UniqJosh
No the local scripts work
When I was originally building the map and testing it out, everything works as normal
It’s only when the map is cloned from replicated storage and moved is when it doesn’t work.