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

How do I remove any velocity from BodyPosition after I am done with it?

Asked by 6 years ago

Hi, I wanted to remove any velocity that was created by the BodyPosition in a part when I am done with it. Even after I remove the BodyPosition from the UpperTorso, the character still has velocity in the Torso and I want to remove this. How do I do this?

Code:

local flying = false

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://1527259193"
local flyAnimTrack = char.Humanoid:LoadAnimation(anim)

mouse.Button1Down:connect(function()
    local bp = Instance.new("BodyPosition", char.UpperTorso)
    flying = true
    bp.MaxForce = Vector3.new(4000, 4000, 4000)
    bp.Name = "LegoFlyPosition"
    bp.Position = mouse.Hit.p
    char.Humanoid.AutoRotate = false
    flyAnimTrack:Play()
    mouse.Move:connect(function()
        if flying == true then
            bp.Position = mouse.Hit.p
            char.UpperTorso.CFrame = CFrame.new(char.UpperTorso.Position, mouse.Hit.p)
        end
    end)
end)

mouse.Button1Up:connect(function()
    char.UpperTorso.LegoFlyPosition:Destroy()
    char.Humanoid.AutoRotate = true
    flyAnimTrack:Stop()
    flying = false
end)
0
You could possibly try adding a counter force to stop the player, possibly -4000,-4000,-4000 in order to push them back with the same force that you pushed them with. Make sure you cut that force off quickly though so it doesnt end up continuing with that force ultrasonicboomer 85 — 6y
0
ok, thanks starwars5251977 48 — 6y

Answer this question