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

I am having issues with positioning through a non humanoid npc?

Asked by 4 years ago

I have a script that makes a non humanoid npc "walk" towards a vector3 value:

function goto(goal)
    repeat
    wait()
    script.Parent.Parent.Parent.Center.Anchored = false
    local mover = script.Parent.Parent.Parent.Center.BodyVelocity
    script.Parent.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.Parent.Center.Position,script.Parent.Value))
    mover.Velocity = script.Parent.Parent.Parent.Center.CFrame.LookVector * 10
    until
    script.Parent.Parent.Parent.Center.Position == script.Parent.Value
end




script.Parent.Changed:Connect(function(newval)
    if newval ~= Vector3.new(0,0,0) then
        goto(newval)
    end
end)

the script works fine however, the exact position is slightly too low for the npc to reach which makes the script keep trying to repeat. is there a way I can have the npc go to its vector3 value, but not have the y axis matter? I still want x and z to be exact.

Answer this question