Hey! I’m just trying to make my user unable to rotate while my tween is playing, and I’m doing it enabling/unabling AutoRotate (humanoid property).
I implemented it on my VFX (local) script and it seems to work just fine with normal movement (just moving as usual, WASD; it works and doesn’t let me rotate my character, as it should), but it doesn’t with shift lock (it doesn’t work and let rotate my character if I use shift lock for it, as it shouldn’t); so I tried doing it server-sided and this issue isn’t happening, but it won’t match with my VFX tween since it is client-sided (client replicated, to avoid tween lagging).
Also, discovered that, if I remove the x.Humanoid.AutoRotate = true
line it works (doesn’t let me rotate even with shift lock) BUT it will be like that forever since I’m not enabling it again.
Script:
function TweenEarth(x) --just a tween: makes the player go smoothly forward -- "x" is character and works perfectly
x.Humanoid.AutoRotate = false --important line
local distance = 5
x.HumanoidRootPart.Anchored = true
local Ray = Ray.new(x.HumanoidRootPart.Position, x.HumanoidRootPart.CFrame.LookVector*distance) --raycasting to don't make the tween go through any parts
local Wall, HitPosition, Normal, Material = workspace:FindPartOnRay(Ray, x)
local length = (x.HumanoidRootPart.Position - HitPosition).Magnitude
local CFrameTween = TweenService:Create(x.HumanoidRootPart,
TweenInfo.new(0.45,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out,0,false,0.4),
{CFrame = x.HumanoidRootPart.CFrame + (x.HumanoidRootPart.CFrame.LookVector*length - x.HumanoidRootPart.CFrame.LookVector*2)})
CFrameTween:Play()
CFrameTween.Completed:Connect(function()
x.HumanoidRootPart.Anchored = false
x.Humanoid.AutoRotate = true --important line
end)
end
EDIT: forgot to mention that this function is fired for all clients!
Thank you for reading, I’d really appreciate your help!