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

Help Me On This Script?

I'm making a Alien that when you kill it, it spawns aliens. But the aliens that spawn don't teleport to the Alien that died any help???

TorsoPos = script.Parent.Torso.Position
SpizerMob = game.Lighting.Spizer
SpizerCount = math.random(1,4)

function SpizerSpawn()
	SpizerMob:clone().Parent = workspace
	wait(1)
	SpizerMob.Torso.Position = Vector3.new(TorsoPos)
end

while wait(1) do
if script.Parent.Alien.Health < 1 then


if SpizerCount == 1 then
	SpizerSpawn()
elseif SpizerCount == 2 then
	SpizerSpawn()
	SpizerSpawn()
elseif SpizerCount == 3 then
	SpizerSpawn()
	SpizerSpawn()
	SpizerSpawn()
elseif SpizerCount == 4 then
	SpizerSpawn()
	SpizerSpawn()
	SpizerSpawn()
	SpizerSpawn()
	wait(1)
end
end
end

1 answer

✓ Accepted answer

On line 1, you're attempting to set the bariable to its position. Actually what you're doing is setting the actual Vector3 value. Your variable should be script.Parent.Torso, and go to TorsoPos.Position every time in the script. Check this out:

TorsoPos = script.Parent.Torso
SpizerMob = game.Lighting.Spizer
SpizerCount = math.random(1,4)

function SpizerSpawn()
    SpizerMob:clone().Parent = workspace
    wait(1)
    SpizerMob.Torso.Position = TorsoPos.Position
end

while wait(1) do
if script.Parent.Alien.Health < 1 then


if SpizerCount == 1 then
    SpizerSpawn()
elseif SpizerCount == 2 then
    SpizerSpawn()
    SpizerSpawn()
elseif SpizerCount == 3 then
    SpizerSpawn()
    SpizerSpawn()
    SpizerSpawn()
elseif SpizerCount == 4 then
    SpizerSpawn()
    SpizerSpawn()
    SpizerSpawn()
    SpizerSpawn()
end
end
     wait(1) --Also moved the wait down to make the wait apply every time the loop runs.
end

1 comment

0

It works but there is one problem the "Spizer" dies when it gets spawned and the first "Spizer" that spawns spawns in a random place :/

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