Tweening scale in one direction

I’m creating a laser beam effect for my game and I’ve been searching the devforum for a solution, but I can’t seem to figure out the issue with my position tweening. I understand to scale a part in a single direction you have to tween both the Size and Position properties, but I can’t figure out how to move the beam part in the opposite direction, my current script just causes it to fly across the map.

    local TweenService = game:GetService("TweenService")

	local beam = Instance.new("Part")
	beam.Shape = Enum.PartType.Cylinder
	beam.Material = Enum.Material.Neon
	beam.Color = Color3.new(1,1,1)
	beam.Anchored = true
	beam.Size = Vector3.new(3,3,3)
	beam.Parent = Character
	beam.Position = Character:FindFirstChild("RightHand").Position
	beam.CanCollide = false
	
	beam.Rotation = Character:FindFirstChild("HumanoidRootPart").Rotation + Vector3.new(0, 90, 0)
	
	local tweeninfo = TweenInfo.new(1)
	local scaletween = TweenService:Create(beam, tweeninfo, {Size = Vector3.new(30, 3, 3)})
	
	local pos = beam.CFrame
	local movetween = TweenService:Create(beam, tweeninfo, {Position = (beam.CFrame * beam.CFrame.Rotation).LookVector})
	
	scaletween:Play()
	movetween:Play()

I got it to work 50% of the time. Half the time it shoots in the intended direction, and the other half the beam goes in the exact opposite direction. This is the code:

local movetween = TweenService:Create(beam, tweeninfo, {CFrame = beam.CFrame - (beam.CFrame * CFrame.Angles(0,math.rad(90),0)).LookVector*beamlength/2})

Try to use CFrame instead of that line

And from my experience there is no such a thing like CFrame.Rotation. Try to avoid that even if it somehow worked for you.

Thank you! This solved the problem

CFrame.Rotation is very useful thing that returns copy of cframe with zero position but with rotation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.