Object = game.Workspace.part -- Defining the part Backup = Object:Clone() -- Cloning the part local find = workspace:FindFirstChild("part") -- Trying to find the part if it exists. if not find then -- Fires the command below if the part does not exist. Backup.Parent = game.Workspace -- The command to be fired. end -- Ending.
Code block and thats all I have worked out but it still dont work.^
It is to regen a part if it is gone. Please help me correct it.
The problem here is that it only checks once. You need to bind this to an event like so:
workspace.ChildRemoved:Connect(function(child) end)
We also need to make sure the clone's parent is not workspace (make it a local):
local Backup = workspace.part:Clone(); Backup.Parent = game:GetService("ReplicatedStorage");
Now we need to detect if the child that was removed was the part and then make a clone to regen it:
workspace.ChildRemoved:Connect(function(child) Backup:Clone().Parent = workspace; end)