How do i do this

basically, im trying to rotate the character towards something that is hit by a raycast, but once the player moves, it isn’t lined up and i want it to always line up whether the instance that the raycast moves, or the player moves, i always want the character facing it. problem is there’s already stuff and loops going on and i don’t know how to incorporate this besides using a totally different script.

if result.Instance.Name == "Head" or result.Instance.Name == "HumanoidRootPart" or result.Instance.Name == "UpperTorso" then
					if firing == false then
						firing = true
						local char = plr.Character
						char:SetPrimaryPartCFrame(,, nil, result.Instance.Position.Z)))
						char.Humanoid.WalkSpeed = 0
						for i = 0,module.burstamount - 1,1 do
							char:SetPrimaryPartCFrame(,, nil, result.Instance.Position.Z)))
							local bullet = module.kerosene:Clone()
							bullet.Parent = workspace
							bullet.Position = module.firepoint.WorldPosition
							module.filled = module.filled - 1
						tool.ToolTip = "Nice weapon for close engagements [FILLED - " .. module.filled .. " ]"
						firing = false
						char.Humanoid.WalkSpeed = 16
1 Like

here’s the problem in video form


you can use a renderstepped loop, set autorotate to false, anchor the humanoidrootpart (this will only solve localplayer moving), or just use a totally different script
just because you have 2 localscripts in your game doesn’t make it bad, it’s more readable if you don’t have a 32000 line script to handle the game

1 Like

im currently looking at what you’ve mentioned. im trying to see what i like the most but i appreciate everything. i just dont want that many scripts because i want it to be organized and “optimized” or whatever, as well as “professional” looking.