So this script basically just spawns a zombie model at one of my spawn points that I designated. But for some reason it’s giving me an error on this line:
local f = workspace.TownCinematicParts.SpawnerZombie.Model[math.random(1,#spawner)]
This is what the workspace view looks like: https://gyazo.com/fd8907e39b492af25fe98bbb883f39ec
function spawnZombie(spawnPos, destination)
local RE = game:GetService("ReplicatedStorage")
local Zombies = RE:WaitForChild("Zombies").IntroCinematicZombies:GetChildren()
local Zombie = Zombies[math.random(1,#Zombies)]:Clone()
Zombie.Parent = workspace
Zombie:MoveTo(spawnPos.Position + Vector3.new(math.random(1,35),5,0))
local Debris = game:GetService("Debris")
Debris:AddItem(Zombie, 30)
end
local spawner = workspace.TownCinematicParts.SpawnerZombie.Model:GetChildren()
local destination = workspace.TownCinematicParts.Destination.Model:GetChildren()
local f = workspace.TownCinematicParts.SpawnerZombie.Model[math.random(1,#spawner)]
local d = workspace.TownCinematicParts.Destination.Model[math.random(1,#destination)]
spawnZombie(f, d)
This is the error message: https://gyazo.com/cbf82c180b1d4ff1a80431a3824fc383
I’m not sure what I’m doing wrong here? It’s like it’s trying to index by name and not by child?