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

how would i check to see if a bodygyro reached its cframe?

Asked by 3 years ago
function Dribble.Left(char,plr,RP,goal,g)   
    local gyro = RP:WaitForChild("BodyGyro")
    local run = game:GetService("RunService")
    local ray = Ray.new(Vector3.new(goal.Position.X,0,goal.Position.Z), (RP.CFrame.RightVector * -10))
    local BodyVelocity = Instance.new("BodyVelocity",char.HumanoidRootPart)
    BodyVelocity.MaxForce = Vector3.new(10000, 00, 10000)
    for i,v in pairs(char:GetDescendants()) do
        if v:IsA("BasePart") then
            v.Massless = true
        end
    end
    repeat wait() until RP.CFrame.lookVector.Unit:Dot((Vector3.new(RP.CFrame.lookVector.X,0,RP.CFrame.lookVector.Z) - Vector3.new(goal.Position.X,0,goal.Position.Z)).Unit) >= 1
    print("reached")
    run.Stepped:connect(function()
        BodyVelocity.Velocity = (Vector3.new(RP.CFrame.RightVector.X,0,RP.CFrame.RightVector.Z) * -1).Unit * 20
    end)
    plr.Character.Humanoid.WalkSpeed = 0
    --wait(.65)
    --plr.Character.Humanoid.WalkSpeed = 16
    --BodyVelocity:Destroy()
end

In this code, I am trying to make the character move ONCE it's facing the target cframe of the bodyGyro. Can anyone help?

Answer this question