Ad
Log in to vote
0

How to correctly write the code for teleporting zombies in different parts of the map?

Asked by 1 month ago
function low_zombie1()
    local platform = game.ReplicatedStorage.MapOne.ZombieSpawn
    local sizeX = math.floor(platform.Size.X / 2)
    local sizeZ = math.floor(platform.Size.Z / 2)
    local sizeY = math.floor(platform.Size.Y / 2)
    local x = math.random(-sizeX, sizeX)
    local z = math.random(-sizeZ, sizeZ)
    local y = math.random(-sizeY, sizeY)
    local position = Vector3.new(x, y+2, z)
    local target = game.Lighting.enemies.ZombieLow1:Clone()
    target.Parent = game.Workspace.ZombiesFolder
    target:makeJoints()
    target:SetPrimaryPartCFrame(platform.CFrame * CFrame.new(position))
end

This is a function of creating a zombie in a specific folder and teleporting it to different areas of the map. I wrote it a long time ago, and abandoned the game for a while. And when I returned, I started writing this error:

19:06:08.365 - Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

Why did she start writing at all? And how do I fix this problem? There are options for how to fix it?

Answer this question