So I’m trying to tween the character up 15 studs from where the raycast hits, however the problem i’m having is the tween completes in weird ways and i cannot understand why, sometimes It stops very early, only a couple studs up, in rare occasions it will complete the 15 stud tween, can anyone help me understand why?
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid = char:WaitForChild("Humanoid")
hrp.Anchored = true
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {char}
local rayOrigin = hrp.Position
local rayDirection = Vector3.new(0, -50, 0)
local raycastResult = workspace:Raycast(hrp.Position, rayDirection, params)
if raycastResult then
local currentPos = hrp.CFrame
local targetCFrame = CFrame.new(currentPos.X, raycastResult.Position.Y + 15, currentPos.Z)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = char:GetPivot()
CFrameValue.Changed:Connect(function(newValue)
char:PivotTo(newValue)
end)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = TweenService:Create(CFrameValue, tweenInfo, {Value = targetCFrame})
tween:Play()
end
end
I can also attach a video if necessary