I want to clone "Map2" from Lighting if it gets removed from Workspace. Here's my attempt which didn't work.
local map = "Map2" local backup = "Map2" local find = game.Lighting:FindFirstChild(backup) local area = workspace if game.Workspace:FindFirstChild(map) then print ("Map found") elseif (backup) then backup:Clone().Parent = area end
The problem with your code is that it is just going to run at the start of the server, and be done.
If you want this to be in effect constantly you should use the ChildRemoved event. This event fires whenever a descendant of the specified object is removed.
Note: Lighting isn't meant for storage, you should use ServerStorage.
Note[2]: There's no need to define the same thing twice.. line 2 is redundant
local map = "Map2" local backup = game.ServerStorage:FindFirstChild(map) workspace.ChildRemoved:connect(function(child) if workspace:FindFirstChild(map) then print ("Map found") else backup:Clone().Parent = workspace end end)
"backup" is just a string. "find" is the actual backup map. So you should do
elseif find then find:Clone().Parent = area end
Next time check the output because I guarantee there are errors.