So I was trying to tween my character to the position with raycasting, but, my character suddenly spins and stops after reaching the goal. On the other hand, when I tween my character’s CFrame it doesn’t make me spin. Please watch the clip below
Tweening with Position:
https://gyazo.com/5a421c2e600f9936cbc3762ea9dc2a62
Tweening with CFrame:
https://gyazo.com/0dfda6120f52fdc310ac7791e941603a
My goal is to tween my player’s position to the raycast so it will keep my player’s orientation.
here’s the code
local ray = Ray.new(Player.Character.HumanoidRootPart.Position,Player.Character.HumanoidRootPart.CFrame.LookVector*range)
local blah,hitpos = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(ray,{Player.Character})
local movetweener = coroutine.wrap(function()
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
local Goal = {}
if hitpos then
humanoid.Parent["HumanoidRootPart"].Anchored = true
Goal.Position = hitpos - (hitpos - humanoid.Parent["HumanoidRootPart"].Position).unit*4
else
Goal.CFrame = humanoid.Parent["HumanoidRootPart"].CFrame*CFrame.new(0,0,-range)
end
local Tween = TweenService:Create(humanoid.Parent["HumanoidRootPart"], tweenInfo, Goal)
Tween:Play()
Tween.Completed:Connect(function(playbackState)
humanoid.Parent["HumanoidRootPart"].Anchored = false
end)
end)
movetweener()