Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can anyone help me make this car regen script do anything?

local RespawnCars = game.Workspace.RespawnCars

function RespawnCars()

print("Time to respawn the cars PUNK!")

for _, object in pairs (game.Workspace.GetChildren()) do

	print(object.Name)

	if object.Name == "Car" then

	print ("This is a car, we need to destroy it!")

	object:Destroy()

	end

	for _, object in pairs (game.ServerStorage:GetChildren()) do

			local carCopy = game.ServerStorage.Car:Clone()

			carCopy.Parent = game.Workspace

			carCopy:MakeJoints()

		end

	end	

RespawnCars.Touched:connect(RespawnCars)

I have put a copy of the cars in SeverStorage and in the workspace but I have also tried only SeverStorage and only workspace, nothing seems to work, The block that people need to touck is called RespawnCars,

please help.

Thanks.

1 answer

Hmm, try this;

local respawnCars = game.Workspace.RespawnCars

function respawnTheCars()

print("Time to respawn the cars PUNK!")

for _, object in pairs(game.Workspace.GetChildren()) do
   print(object.Name)
   if object.Name == "Car" then
   print ("This is a car, we need to destroy it!")
   object:Destroy()
   end
          local carCopy = game.ServerStorage.Car:Clone()
           carCopy.Parent = game.Workspace
           carCopy:MakeJoints()
        end
   end


respawnCars.Touched:connect(respawnTheCars)

`

This discussion is preserved as it was. New answers, comments, and votes are closed.