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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)

`

Ad

Answer this question