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

Can someone help me make a following monster?

Asked by 7 years ago

I am trying to make a following npc, can someone help me? I am a beginner scripter and this is my first time trying to make a following script and cant figure out how plz help :C

0
just go to tools and type in "zombie" or something sweetlittlegirlohhl -22 — 7y
0
not helpful, i dont take free models lukebloxdaily 6 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

There

01local list = game.Workspace:children()
02local dist = 500 -- Change to the distance you want the Zombie to find people
03local time = 0.1 --Change to how long you want the Zombie to find and chase people (I recommend 0.1)
04 
05while true do wait(time)
06    for x = 1, #list do
07        local temp2 = list[x]
08        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
09          local temp = temp2:findFirstChild("Torso")
10           local human = temp2:findFirstChild("Humanoid")
11            if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
12                if (temp.Position - script.Parent.Torso.Position).magnitude < dist then
13                 script.Parent.--[[Zombies//Change to name of whatever you put this into]]:MoveTo(temp.Position, temp)
14                end             --Then remove the text and these: -- [[ ]]
15            end
16        end
17    end
18end
0
thx, so i put this straight in the model? (model is da zombie) lukebloxdaily 6 — 7y
0
it doesnt work, rip Dx lukebloxdaily 6 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

Here try this, make sure it's in a model with a Humanoid, and also make sure the model is not anchored.

01local larm = script.Parent:FindFirstChild("Left Arm")
02local rarm = script.Parent:FindFirstChild("Right Arm")
03 
04function findNearestTorso(pos)
05    local list = game.Workspace:children()
06    local torso = nil
07    local dist = 1000
08    local temp = nil
09    local human = nil
10    local temp2 = nil
11    for x = 1, #list do
12        temp2 = list[x]
13        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
14            temp = temp2:findFirstChild("Torso")
15            human = temp2:findFirstChild("Humanoid")
View all 37 lines...

Answer this question