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

why does the zombie spawner not spawn in the right place?

Asked by 3 years ago
Edited 3 years ago

[ok i found solution]

script.Parent.Transparency = 1 

while wait(math.random(29, 90)) do -- random time to spawn
    z = game.ReplicatedStorage.zombie:Clone()
    local hp = z.Humanoid.MaxHealth
    z:MoveTo(script.Parent.Position) -- move to the spawner's location
    z.Parent = workspace
    z.Humanoid.MaxHealth = math.random(25,100) -- random health
    z.Humanoid.Health = z.Humanoid.MaxHealth
    if hp < 50 then --change skin collor due to health
        z["Left Arm"].Color = Color3.fromRGB(39, 70, 45)
        z["Right Arm"].Color = Color3.fromRGB(39, 70, 45)
        z["Head"].Color = Color3.fromRGB(39, 70, 45)
    else

        z["Left Arm"].Color = Color3.fromRGB(52, 142, 64)
        z["Right Arm"].Color = Color3.fromRGB(52, 142, 64)
        z["Head"].Color = Color3.fromRGB(52, 142, 64)

    end
end

it just ignores line 6 for some reason [ok i found solution]

0
I'm pretty sure that the humanoid is what you are supposed to call MoveTo() with cmgtotalyawesome 1418 — 3y
0
So just change line 6 to z.Humanoid:MoveTo(script.Parent.Position) cmgtotalyawesome 1418 — 3y
0
Any errors? Omq_ItzJasmin 666 — 3y
0
No errors but the first time i wrote without z:MoveTo it worked now it doesnt work and the z.humanoid:moveto(script.parent.position) doesnt work fullguyblox3 69 — 3y

1 answer

Log in to vote
0
Answered by
sayer80 457 Moderation Voter
3 years ago
Edited 3 years ago

2 Things I changed:

  1. Put Waiting at the End and not inside while ... do so it always has a random time

  2. SetPrimaryPartCFrame instead of MoveTo

script.Parent.Transparency = 1 

while true do -- random time to spawn

    z = game.ReplicatedStorage.zombie:Clone()
    local hp = z.Humanoid.MaxHealth
    z:SetPrimaryPartCFrame(script.Parent.Position) -- move to the spawner's location
    z.Parent = workspace
    z.Humanoid.MaxHealth = math.random(25,100) -- random health
    z.Humanoid.Health = z.Humanoid.MaxHealth
    if hp < 50 then --change skin collor due to health
        z["Left Arm"].Color = Color3.fromRGB(39, 70, 45)
        z["Right Arm"].Color = Color3.fromRGB(39, 70, 45)
        z["Head"].Color = Color3.fromRGB(39, 70, 45)
    else

        z["Left Arm"].Color = Color3.fromRGB(52, 142, 64)
        z["Right Arm"].Color = Color3.fromRGB(52, 142, 64)
        z["Head"].Color = Color3.fromRGB(52, 142, 64)

    end
wait(math.random(29, 90)) 
end
0
the setprimarycframe made Unable to cast Vector3 to CoordinateFrame error and when i removed '.Position' it makes Unable to cast Instance to CoordinateFrame error fullguyblox3 69 — 3y
Ad

Answer this question