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(CFrame.new(char.HumanoidRootPart.CFrame.Position, Vector3.new(result.Instance.Position.X, nil, result.Instance.Position.Z)))
wait(module.aimtime)
char.Humanoid.WalkSpeed = 0
for i = 0,module.burstamount - 1,1 do
wait(0.1)
char:SetPrimaryPartCFrame(CFrame.new(char.HumanoidRootPart.CFrame.Position, Vector3.new(result.Instance.Position.X, nil, result.Instance.Position.Z)))
local bullet = module.kerosene:Clone()
bullet.Parent = workspace
module.firesound:Play()
bullet.Position = module.firepoint.WorldPosition
module.filled = module.filled - 1
end
tool.ToolTip = "Nice weapon for close engagements [FILLED - " .. module.filled .. " ]"
firing = false
char.Humanoid.WalkSpeed = 16
end
end