So I have this script that make the player focuses on an npc but for some reason it freak when in its on the client. in the server it works just fine. What Can in do to fix it?
Video https://vimeo.com/721773897
Code:
local Camera = workspace.CurrentCamera local Goal = workspace.Enemies:FindFirstChild(chainedEnemyGlobal) while true do wait(0.01) Camera.CameraType = Enum.CameraType.Scriptable Camera.CameraSubject = player.Character.Head character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position) * CFrame.Angles(0,Vector3.new(CFrame.new(character.HumanoidRootPart.Position, Goal.Head.Position):ToOrientation()).Y,0) end
I don't know if this will solve it, but instead of using a while loop, you can use "RunService.RenderStepped" instead. Your code would look like this with it.
local Camera = workspace.CurrentCamera local Goal = workspace.Enemies:FindFirstChild(chainedEnemyGlobal) local RunService = game:GetService("RunService") RunService.RenderStepped:Connect(function() Camera.CameraType = Enum.CameraType.Scriptable Camera.CameraSubject = player.Character.Head character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position) * CFrame.Angles(0,Vector3.new(CFrame.new(character.HumanoidRootPart.Position, Goal.Head.Position):ToOrientation()).Y,0) end)