How to make the line dont glitch

It just does some glitchy things, when I try to repeat look at I want it smoothly

repeat
					character.HumanoidRootPart.CFrame = CFrame.lookAt(character.HumanoidRootPart.Position, DoorInteract.Position)
					game["Run Service"].Heartbeat:Wait()
				until player.Knocking.Value == false

I forgot to post the video. (The reason why I’m blurring my game name so you wont get my idea by stealing it because I have a extremely good concept and I don’t want it to get stolen)

2 Likes

Your root part looks up because the lookAt math includes the doors Y position

Fix this by using the doors X and Z, but your root parts Y:

CFrame.lookAt(character.HumanoidRootPart.Position, Vector3.new(DoorInteract.Position.X, character.HumanoidRootPart.Position.Y, DoorInteract.Position.Z))
1 Like

It almost works but when I move it [like W A S D keys or Arrow keys to make your character move] kinda bugs out how do I fix it (similar to the video)

would you be able to make another video?

1 Like

Sure, Im going to make one right now

1 Like

If you mean the jittering, it’s possible it’s in a server script. You could swap it to a LocalScript for the movements to be smoother for the player.

If it’s the moving around, then I’m really unsure with the really small code snippet.

Heres my code for reference (inside of a localscript):

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character

local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Root = Humanoid.RootPart

local TargetPart = workspace:WaitForChild("Object")

RunService.Heartbeat:Connect(function()
	Root.CFrame = CFrame.new(Root.Position, Vector3.new(TargetPart.Position.X, Root.Position.Y, TargetPart.Position.Z))
end)

Make the client handle effects and movements, and make the server handle the rest.

I forgot to tell you that the script I made its on the severscript

Yeah, this should be the cause of the jittering, since the server can’t really send information to you at the same rate that your client would be able to CFrame that in a LocalScript.

Well, do I have to use remote events?

The client can also connect to the proximity prompt, but if you really want to, you can use remote events.

How?


			local character = player.Character or player.CharacterAdded:Wait()

			local Humanoid = character:FindFirstChildOfClass("Humanoid")
			local Root = Humanoid.RootPart

			local TargetPart = DoorInteract
			
			
			task.spawn(function()
				
				
				repeat
					

					game["Run Service"].Heartbeat:Connect(function()
						Root.CFrame = CFrame.new(Root.Position, Vector3.new(TargetPart.Position.X, Root.Position.Y, TargetPart.Position.Z))
					end)

					
				until player.Knocking.Value == false
			end)
			

You shouldn’t use a repeat in that way it’s spam creating connections.

Instead, you can simply connect it and then disconnect it.

You can connect to the proximity prompt by using the same method the server uses, but from your client.

Im just going to remove the line for now and replace with something else, thanks for helping

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.