I'm trying to clone a copy of my car into workspace again if it is driven off the baseplate, or even removed. When I tested, this didn't work.
lighting = game.Lighting carcopy = lighting.CarCopy car = game.Workspace.Car workspace = game.Workspace while true do wait(1) if car.Parent ~= workspace then carcopy:Clone() elseif car.Parent == workspace then print("Car still in workspace") end wait(1) end
I've had this same problem too, try this instead;
local car = game.Workspace.Car:Clone() --This will clone the Car [As an extra copy] while wait(1) do --This will repeat waiting 1 second(s) and doing the code below if not game.Workspace:FindFirstChild("Car", true) then --If not script finds 'Car' within Workspace then local newCar = car:Clone() --This will clone the Extra car newCar.Parent = game.Workspace --Parent it to the Workspace newCar:MakeJoints() --And make the Joints for it end --This ends the code block for the 'if' statement end --This ends the code block for the 'while true do end' loop
If this code does not work, or it is not complying with what your asking, then just let me know. :P Hope this helped!
The car that you cloned from Lighting, it's parent is nil and the script would've broke. Do this:
lighting = game.Lighting carcopy = lighting.CarCopy car = game.Workspace.Car workspace = game.Workspace while true do wait(1) if car.Parent ~= workspace then carcopy:Clone() carcopy.Name = "Car" carcopy.Parent = workspace elseif car.Parent == workspace then print("Car still in workspace") end wait(1) end
This should work now.
Hahahah. LOL. When it's drove off the map, it's 'destroyed.' Thus, it's parent is nil and is locked. so;
lighting = game.Lighting carcopy = lighting.CarCopy car = game.Workspace.Car workspace = game.Workspace while true do if game.Workspace:FindFirstChild("Car") = false then --assuming it's called "Car" local c=carcopy:Clone() c.Name = "Car" elseif car.Parent == workspace then print("Car still in workspace") wait(1) end wait() end