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

How to make a clone machine with time interval?

Asked by 3 years ago

I am trying to make a cloning machine where the "clones" will spawn on a part named "Part" at every X time interval(eg. 3 secs). But it seems not be looping(the script).

local zombie = game:GetService("ServerStorage").AssortedCrystal115

local spawner = script.Parent


wait(0.1)
while true do
    wait(0.1)
    local zom = zombie:Clone()
    local root = zom.HumanoidRootPart
    root.CFrame = CFrame.new(spawner.Position) + Vector3.new(0,math.random(1,3),0)
    zom.Parent = workspace.Clones
    print("Assorted")
end

Thanks.

1 answer

Log in to vote
0
Answered by 3 years ago

Something you should do is revise your first line from

local zombie = game:GetService("ServerStorage").AssortedCrystal115

to this:

local storage = game:GetService("ServerStorage")
local zombie = storage:WaitForChild("AssortedCrystal115")

Another thing I'd recommend is changing ServerStorage to ReplicatedStorage and moving your npc there (this isn't required, just recommended).

Ad

Answer this question