Need help with extending Kamehameha beam

Making a kamehameha thing for a game im doing with my friend, clearly not done so don’t worry about how it moves or that the explosion goes with the mouse lol

trying to figure out how to extend the beam towards the cursor

if i just try to resize it it’ll obviously go in both directions

i’ve tried moving it forward to equate for how much would be going backwards but no matter what i did it wouldn’t go straight, it would head off in some crazy direction (also this doesn’t feel like a very efficient solution to me, and it would break the weld so ¯_(ツ)_/¯)

^^ if this is the ideal solution then if someone could explain how i would actually go about doing this that would also be appreciated

the kamehameha model in front of the character is 3 parts, 2 spheres and a cylinder, only the smaller sphere is anchored and the 2 other parts are welded to it. the model is also a child of the player model if that means anything.

– very unfinished code, not sure if this is necessary but it should add some context (removed the failed attempt to move the beam forward)

-- functions

-- input began
UIS.InputBegan:Connect(function(input, gP)
	if input.KeyCode == Enum.KeyCode.E then
		
		-- vars
		isAttacking = true
		
		local mousePos = mouse.Hit.Position

		local beam = attacks.Kamehameha.Beam:Clone()
		local expl = attacks.Kamehameha.Explosion:Clone()
		

		root.Anchored = true


		beam.Parent = chr
		expl.Parent = chr
		-- sets locations
		beam.MainPart.CFrame = root.CFrame*CFrame.new(Vector3.new(0,0,-2))
		
		chr.Explosion.MainPart.CFrame = CFrame.new(mousePos)
	end
end)



-- input ended
UIS.InputEnded:Connect(function(input, gP)
	if input.KeyCode == Enum.KeyCode.E then
		isAttacking = false
		
		root.Anchored = false
		
		chr.Beam:Destroy()
		chr.Explosion:Destroy()
	end
end)


-- on mouse move
mouse.Move:connect(function()
	local mousePos = mouse.Hit.Position
	
	if isAttacking == true then
		-- makes character face direction of beam
		root.CFrame = CFrame.new(root.Position, mousePos)
		
		-- beam offset from character
		chr.Beam.MainPart.CFrame = root.CFrame*CFrame.new(Vector3.new(0,0,-2))
		
		-- creates explosion
		chr.Explosion.MainPart.CFrame = CFrame.new(mousePos)
		
		
	end

end)

any help is appreciated

+also if there’s any information i forgot that’s required please let me know

1 Like
root.CFrame*CFrame.new(Vector3.new(0,0,-beam.MainPart.Size.X/2))
 --change X to the largest size

have you tried resizing it and moving its position? im not sure if it’ll work or not though

i had tried it before but it wasn’t working for a few reasons, im trying it again because @Kaid3n22 solved one of those for me. making some progress

root.CFrame * (root.CFrame.LookVector * (beam.MainPart.Size.X/2))