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

How do you Create a Zombie Script?

Asked by
SirPaco 66
9 years ago

I attempted to create a Zombie Script where the Zombie follows you and kill you. I made a huge attempt of Scripting the Zombie to follow you but I could not figure out how to get it to kill you. I desperately need assistance on both of those. Below is what I attempted to Script:

local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
distance = script.Parent.Configuration.distance.Value 

function findNearestTorso(pos)
    local list = game.Workspace:children()
    local torso = nil
    local dist = distance 
    local temp = nil
    local human = nil
    local temp2 = nil
    for x = 1, #list do
        temp2 = list[x]
        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
            temp = temp2:findFirstChild("Right Arm")
            human = temp2:findFirstChild("Humanoid")
            if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
                if (temp.Position - pos).magnitude < dist then
                    torso = temp
                    dist = (temp.Position - pos).magnitude
                end
            end
        end
    end
    return torso
end




while true do
    wait(math.random(1,1))
    local target = findNearestTorso(script.Parent.Torso.Position)
    if target ~= nil then
        script.Parent.Humanoid:MoveTo(target.Position, target)
    end

end
0
code block pls NotSoNorm 777 — 9y
0
Edited to add code block. BlueTaslem 18071 — 9y
0
<3 NotSoNorm 777 — 9y
0
Sorry, it is difficult to add. I am new here! SirPaco 66 — 9y
View all comments (4 more)
1
In the future -- select all of your code, and press the Lua button above the text box. A line of ~~~ will appear before and after the code. BlueTaslem 18071 — 9y
0
Thanks. SirPaco 66 — 9y
0
Why are you doing 'wait(math.random(1, 1)) YellowoTide 1992 — 9y
0
I forget. I was trying to make it work for a very long time and I was getting very stressed and depressed. SirPaco 66 — 9y

Answer this question