Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this Regeneration Script not working properly?

Asked by 5 years ago
Edited 5 years ago

can anyone point out the error with this code - it seems to be "grammatically" fine but when it runs i get the following error ""The Parent property of Map1 is locked, current parent: NULL, new parent Workspace""

yours - goku

local map = game.Workspace.Map1 
map.Parent = game.ServerStorage
local mapCopy = map:Clone()
local mapCopy 
local function Regen()
    wait(6)
    mapCopy:destroy()
    mapCopy.Parent = game.Workspace 
    wait(3)
end

mapCopy.Parent = game.Workspace
while true do
    Regen()
end

0
if you want any more information just ask and ill be happy to awnser ScriptingNubs 55 — 5y
0
Please use code blocks User#19524 175 — 5y
0
sorry just realized that -once again sorry for my insolence ill fix if up now ScriptingNubs 55 — 5y

1 answer

Log in to vote
1
Answered by
Azuc 112
5 years ago
Edited 5 years ago

It was a little hard to read what your script exactly said due to it not being in code blocks but I believe the following code will do exactly what you are trying to do:

local StoredMap = game:GetService("ServerStorage").Map1  --//Location of stored map.

local function Regen()
    wait(6)
    game.Workspace:FindFirstChild("Map1"):Destroy()  --//Remove copy from Workspace.
    wait()
    local Copy = StoredMap:Clone() --//Clone copy from Server Storage.
    Copy.Parent = game.Workspace --// Insert new copy.
end

while true do
    Regen() --//Run the regen function.
end
Ad

Answer this question