How to make cylinder tween and go along a mouse look vector?

I have been trying to make a beam aka a Kamehameha extend in the direction of where the mouse is facing but i don’t really know how to go about doing it. I have tweened the end part to go along the mouse vector and the beam to tween foward so far.

bigBall:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3))
	bigBall.Parent = workspace.Ignore
	
	beam:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3))
	
	
	
	
	for i,parts in pairs(beam:GetChildren()) do
		if parts:IsA("BasePart") then
			parts.Orientation = parts.Orientation + Vector3.new(0,90,0)
		end
	end
	
	beam.Parent = workspace.Ignore
	
	BigBallEnd:SetPrimaryPartCFrame(char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3))
	BigBallEnd.Parent = workspace.Ignore

	
	local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
	
	local X_INCREMENT = 500;
	
	
	local endTween = {Size = beam.PrimaryPart.Size + Vector3.new(X_INCREMENT, 0, 0),

		CFrame = beam.PrimaryPart.CFrame * CFrame.new(X_INCREMENT/2,0,0) 
	}
	local tweenbeam = tweenService:Create(beam.PrimaryPart, tweenInfo, endTween)
	
	tweenbeam:Play()
	
	tweenModelSizeXIncrement(beam, 500, 3)
	

	local endTweenBig = {CFrame =  CFrame.new(BigBallEnd.PrimaryPart.Position +  mouseHit.LookVector * 500 ) }
	
	for i,parts in pairs(BigBallEnd:GetChildren()) do
		if parts:IsA("BasePart") then
			local tween = tweenService:Create(parts, tweenInfo, endTweenBig)
			tween:Play()
		end
	end

1 Like

Idk, but try:

local UserInputService = game:GetService("UserInputService")
local distance=1000000
local ray=workspace.CurrentCamera:ScreenPointToRay(UserInputService:GetMouseLocation().X,UserInputService:GetMouseLocation().Y).Unit
local target=ray.Origin+(ray.Direction*distance)

you could just use CFrame:lookAt() with ‘target’ and get a cframe that looks to mouse location
the more you set ‘distance’, the more accurate it is. (i think)