Problem : My character is glitching when i try to move the mouse. The Character should look at the mouse when it moves
The below link is what i have made with the manipulation that glitches
The below script control the Manipulation
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
while wait() do
if workspace:FindFirstChild(player.Name.."Camera") then -- this is the name of the camera
workspace.CurrentCamera.CameraType = Enum.CameraType.Track
workspace.CurrentCamera.CFrame = workspace:FindFirstChild(player.Name.."Camera").CFrame
local char = player.Character or player.CharacterAdded:Wait()
local cam = workspace:FindFirstChild(player.Name.."Camera")
local Root = char:FindFirstChild("HumanoidRootPart")
cam.CFrame = char:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0,50,0)
cam.Orientation += Vector3.new(-90,0,0)
mouse.Move:Connect(function()
Root.CFrame = CFrame.new(Root.Position, Root.Position + Vector3.new(mouse.Hit.lookVector.x, 0, mouse.Hit.lookVector.z))
wait(.5)
end)
print("yes")
end
wait()
end
I just scripted this for getting knowledge of camera manipulation, so if u know any solution pls tell me.
Sorry, but you have to be more clear. Can you provide a visual of the camera manipulation you want to achieve? Hmm, lookvector returns the direction of the mouse’s axis, so if you moving around / orientating, your character would probably have a spasm. I don’t think lookVector is needed in this case because you can just use mouse.Hit.p on each axis, probably with an exception on the Y axis.
Sorry, but my pc lags and everything happens very slowly when i try to record something , so i have provided the game links of what i want to script and the game I’ve scripted in the post.
Your given line does the same thing as I’ve scripted. I just need it to be smoother . Btw thanks for the help.
I assume this is a client script so I recommend using RunService.HeartBeat:Wait() or RunServer.RenderStepped (all your code will be in this event so no while loop)
@Codez_X , @Xx_FROSTBITExX and @Beastcraft_Gaming Thank you all for ur effort of helping me but i have got the solution , I just disconnected the mouse.Move function after a second and its working without any gltiches
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
while wait() do
if workspace:FindFirstChild(player.Name.."Camera") then
workspace.CurrentCamera.CameraType = Enum.CameraType.Track
workspace.CurrentCamera.CFrame = workspace:FindFirstChild(player.Name.."Camera").CFrame
local char = player.Character or player.CharacterAdded:Wait()
local cam = workspace:FindFirstChild(player.Name.."Camera")
local Root = char:FindFirstChild("HumanoidRootPart")
cam.CFrame = char:FindFirstChild("HumanoidRootPart").CFrame + Vector3.new(0,50,0)
cam.Orientation += Vector3.new(-90,0,0)
local connection = mouse.Move:Connect(function()
Root.CFrame = CFrame.new(Root.Position, Root.Position + Vector3.new(mouse.Hit.lookVector.x, 0, mouse.Hit.lookVector.z))
wait(.5)
end)
wait(1)
connection:Disconnect()
print("yes")
end
end