Nothing wrong with being new to scripting, we were all there.
In order to shift where the cloned object is, you have to change the parent property of the object.
So instead of doing "MODEL_BACKUP = game.ReplicatedStorage" you would type "MODEL_BACKUP.Parent = game.ReplicatedStorage"
The second thing is on line 9, you say "WaitForChild(REGEN)" which will not work for several reasons.
*REGEN was destroyed and has it's parent value locked to nil
*WaitForChild take a string, and you're passing in an object
If you wanted to wait for the new TestHouse, you would just do "game.ReplicatedStorage:WaitForChild("TestHouse")" or you could even do "game.ReplicatedStorage:WaitForChild(MODEL_BACKUP.Name)"
The second one uses the name of MODEL_BACKUP as it should be the same as REGEN.Name which will be "TestHouse".
Lastly we need to talk about how you're setting the variables and how since this is a loop will eventually fail. How your code is written, after we changed everything to conform to Lua, will still have a logical problem. Every minute, it makes MODEL_BACKUP which is the original clone of REGEN and we set it's parent to ReplicatedStorage. Then we destroy REGEN, but on the second go destroying the REGEN variable doesn't make sense, we already did it once.
We can fix these logical errors by thinking back to what you wanted to do in the first place: Clone an object, move the clone to ReplicatedStorage. Destroy the original object in workspace, and move the clone into workspace.
In this case, I can rewrite most of the logic fairly easily.
This whole thing could be rewritten as:
local REGEN = game.Workspace.TestHouse
local MODEL_BACKUP = REGEN:Clone()
local work = game.Workspace
while true do
wait(60)
REGEN:Destroy()
MODEL_BACKUP.Parent = work
REGEN = MODEL_BACKUP
MODEL_BACKUP = REGEN:Clone()
end
If you have any other questions feel free to message me.
1 comment
It's extremely difficult to understand what you're trying to do. Please consider rewording your question.