How would I make this thing rotate? (more info in desc)

So im tryna make a katyusha type of thing and I have a system where it launches the missile and calculates the distance but the rotation has to be correct and im wondering how / if I can use lookVector or something else to turn the missle / missle holders towards the right direction.

image
(pretend that there is actually a launching thing connected to the base)

here is a video (without any turning: roblox pc crashing rocket barrage - YouTube)

I cloned the missle and made it go up so that if it tries to move sideways, it doesn’t bump into other missiles. Is there also a way to make the missiles face the way its going? Here is the code:



local filter = OverlapParams.new()
filter.FilterType = Enum.RaycastFilterType.Blacklist 
filter.FilterDescendantsInstances = { workspace.Model:GetDescendants() }




while  wait(.1) do
for i,v in pairs(script.Parent:GetChildren()) do
	if v.Name == "Missile" then
		local pos1 = v.Position
		local pos2 = workspace.Part.Position + Vector3.new(math.random(-500,500),0,math.random(-500,500))
		local direction = pos2-pos1
		local duration = math.log(1.001+direction.Magnitude * 0.01)
		local force = direction/duration + Vector3.new(0,workspace.Gravity* duration * 0.5,0)
		print(duration)
		local clone = v:Clone()
			clone.Position = pos1
			clone.CFrame = CFrame.lookAt(pos1,pos2) + Vector3.new(2,3,2)
		clone.Parent = workspace
		clone.Anchored = false
		clone:ApplyImpulse(force*clone.Mass)
		clone:SetNetworkOwner(nil)
			task.spawn(function()
				wait(1)
				clone.Touched:Connect(function()
					local exp = Instance.new("Explosion")
					exp.Parent = workspace
					exp.Position = clone.Position
					exp.BlastRadius = 150
					exp.BlastPressure = 15000
					
					clone:Destroy()
					wait(0.2)
					exp:Destroy()
				end)
			end)
		



		wait(0.05)
	end
	end
end

No need to make another post, you could have continued in the previous post. pos2 should be changed to something like this:

local pos2 = workspace.Part.Position + workspace.Part.CFrame.LookVector

This code does look very laggy and probably is going to crash your PC due to a memory leak.

ah alr, but how can I make the whole thing “turn” to its target?


the missiles shoot in a straight line and if everything isn’t aligned, then it breaks…

workspace btw if you need it:

hey! Update: I managed to get it work but do you know how I could do it?
new code:



local filter = OverlapParams.new()
filter.FilterType = Enum.RaycastFilterType.Blacklist 
filter.FilterDescendantsInstances = { workspace.Model:GetDescendants() }




while  wait(0.5) do
for i,v in pairs(script.Parent:GetChildren()) do
	if v.Name == "Missile" then
		local pos1 = v.Position
			local pos2 = workspace.Part.Position + workspace.Part.CFrame.LookVector
		local direction = pos2-pos1
		local duration = math.log(1.001+direction.Magnitude * 0.01)
		local force = direction/duration + Vector3.new(0,workspace.Gravity* duration * 0.5,0)
			print(duration)
			script.Parent.Parent.Model:SetPrimaryPartCFrame(CFrame.lookAt(script.Parent.Parent.Model.PrimaryPart.Position, pos2))
		local clone = v:Clone()
			clone.Position = pos1
			clone.CFrame = CFrame.lookAt(pos1,pos2) + Vector3.new(2,3,2)
		clone.Parent = workspace
		clone.Anchored = false
		clone:ApplyImpulse(force*clone.Mass)
		clone:SetNetworkOwner(nil)
			task.spawn(function()
				wait(1)
				clone.Touched:Connect(function()
					local sfx = Instance.new("Sound")
					sfx.Parent = clone
					sfx.SoundId = "rbxassetid://5801257793"
					sfx.Volume = 0.5
					print(sfx.Parent)
					local exp = Instance.new("Explosion")
					exp.Parent = workspace
					exp.Position = clone.Position
					exp.BlastRadius = 150
					exp.BlastPressure = 15000
					
					
					sfx:Play()
					
					
					wait(0.5)
					clone:Destroy()
					exp:Destroy()
					
					
				end)
			end)
		



		wait(0.05)
	end
	end
end

new workspace:
image