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

Changing Player CFrame forces the player, then moves back?

Asked by
SGII2 0
4 years ago

Hey, there! I've been trying to make a homing attack sort of thing, and I'm moving the Player's CFrame to do it. It does reach its goal, but then it moves to the side or backwards a bit. I would like it to not be moving back. Here's my code:

for i = 1,50 do
            local tor = localPlayer.Character:WaitForChild('UpperTorso')
            local cam = workspace.CurrentCamera

            if not stop then
                tor.Parent.UpperTorso.CFrame = tor.CFrame
                            --How much you want to move them
                            * CFrame.new((CFrame.new(0,2,2)
                            --Multiplied by lookVector of the Camera's CoordinateFrame
                            * tor.CFrame.lookVector * 1))

                wait(0.01)
            end

            tor.Touched:Connect(function()
                stop = true
            end)

            tor.Parent.Head.Touched:Connect(function()
                stop = true
            end)

Thank you.

Answer this question