Hey guys, I was trying to make a script that would have the player face an object for a certain period of time, where they would still be able to move. However, I encountered this issue where changing the orientation / rotation of the y axis would consequently lag back the character, and just freeze them in place if in a loop. Heres the code:
local function rotate(Player, test)
local chrPos = Player.Character.PrimaryPart.Position
local tPos = test.Position
local modTPos = (chrPos - tPos).Unit * Vector3.new(1,0,1)
local upVector = Player.Character.PrimaryPart.CFrame.UpVector
local newCF = CFrame.lookAt(chrPos, chrPos + modTPos, upVector) * CFrame.fromAxisAngle(Vector3.new(0, 1, 0), math.pi)
end
Humanoid.AutoRotate = false
local func = coroutine.wrap(function()
while Debounce.Value == true do
rotate(Player, test)
wait(0.03)
end
end)
func()
To reiterate, this code will cause the player to freeze in place and not allow them to move while running (but I don’t really want that). any ideas? I tried also changing it with the Pivot function but it still had the same issue, so im really looking for some feedback on this