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

How do I use Spawn Function is this correct?

Asked by 4 years ago

Why isn't this working

Zombie = game.ServerStorage.Zombie
cz = Zombie:Clone(workspace)
spawn(cz)

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

What are you trying to achieve with this script? And a quick search shows the correct usage of spawn(), "Spawn is used to run a function in a separate thread without yielding the current one. It will run simultaneously with the rest of the tasks, but won’t delay/affect the main thread." If you are trying to 'spawn' a zombie into the game you would clone it to the workspace(which you have done), and then set it's position to wherever you want it to appear.

EDIT: there would be at least two ways to make it 'spawn' you would either specify the position it should be at, like this

Zombie = game.ServerStorage.Zombie
cz = Zombie:Clone()
cz.Parent = game.Workspace
cz.UpperTorso.Position = Vector3.new(0, 0, 0)

Or, you could set a block in the workspace that is invisible and has can collide off, and you would do something like this

Zombie = game.ServerStorage.Zombie
cz = Zombie:Clone()
cz.Parent = game.Workspace
cz.UpperTorso.Position = workspace.czspawn.Position

If you have any other problems or questions just let me know

0
How can I set the spawn? Thx FluffySheep46209 369 — 4y
0
let me know if it worked or not so i can see if I can find the problem jediplocoon 877 — 4y
0
It still dosen't work,I'm not sure why FluffySheep46209 369 — 4y
0
I tested it out and found an error, try the edited code now jediplocoon 877 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

No, that is not how you use it. It is used to spawn functions while going on with the script. Their most common use is with while true do loops, like this one:

local function doLoop()
    while true do
        print("Hello World!")
        wait()
    end
end

spawn(doLoop)

while true do 
    print("Bob")
    wait()
end

Both while true do's will run.

Answer this question