The following script triggers way too late and you’d have already gone through the wall by the time the tween cancels. I hope you understand what I’m trying to do.
local root = game.Players.LocalPlayer.Character.HumanoidRootPart
local tween = game:GetService("TweenService"):Create(
root,
TweenInfo.new(.1, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
{CFrame = character.HumanoidRootPart.CFrame*CFrame.new(0,0,-20)}
)
root.Touched:Connect(function(part)
if part.Anchored and part.CanCollide then
tween:Cancel()
end
end)
wait(.2)
tween:Play()