New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 10 days 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