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

Can anyone help me with my alien script?

Asked by 8 years ago

So i looked up a tutorial on how to make a zombie script and used it for a custom alien i made it detects the player but it doesn't move any help? heres the script so you can see it:

torso = script.Parent.Torso
range = 20
target = nil

function findNearestTarget()
    plrs = game.Players:GetChildren()
    for i, plr in ipairs(plrs) do
        if plr.Character ~= nil then
            tor = plr.Character.Torso
            if target ~= nil then
            if (torso.Position-tor.Position).magnitude < (torso.Position-target.torso.Position).magnitude then

                break
            end 

            elseif (torso.Position-tor.Position).magnitude <= range then
print(plr.Name.."is in range")  
break       
                end
            end
        end
    end

while true do
    wait(.1)
    findNearestTarget()
    if target ~= nil then
        script.Parent.Alien:MoveTo(target.Torso.Position)
    end
end
1
To make the Alien walks to its associated target you'll need to use MoveTo() on the Humanoid rather than the model since that will position the whole model to the target's position UserOnly20Characters 890 — 8y
1
it is moving the aliens humanoid because i named the humanoid Alien Thegrimdeathzombie 40 — 8y

Answer this question