Tweening the Z Axis Only

So i’m trying to make a beam attack but I don’t want to refer to the Y or X axis at all, I don’t want to do something like this:

v.Size = v.Size + Vector3.new(anumber,anumber,anumber)

I don’t want to do this because when you get v.Size, it stays locked at that size which I don’t want, since i should repeatedly be changing the size

this is the current script

		for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal =  {
						v.Size.Z == Vector3.FromAxis(Enum.Axis.Z,800)
					}		
					goal.CFrame = v.CFrame * CFrame.new(0,0,-400)
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal)
					tween:Play()
				end
			end
		end

but the problem with this is that i get:
Unable to cast to dictionary

The problem is that your goal parameter is incorrect. I don’t really understand what you meant when you wrote:

local goal =  {
				v.Size.Z == Vector3.FromAxis(Enum.Axis.Z,800)
		      }		
				goal.CFrame = v.CFrame * CFrame.new(0,0,-400)

It give the effect of moving forward
this was the old script

	for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal = {}
					goal.Size = v.Size + Vector3.new(0,0,800)
					goal.CFrame = v.CFrame * CFrame.new(0,0,-400)
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal)
					tween:Play()
				end
			end
		end

this resulted in


but I want the beam to constantly get bigger then smaller using a spawn function, which is why I only want to tween the z axis

1 Like

I see, that looks epic by the way. So is the tween not working with this new script? If so are there any errors?

The only error i’m getting using this script is : ‘Unable to Cast to Dictionary’


		for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal =  {
						v.Size.Z == Vector3.FromAxis(Enum.Axis.Z,800)	,
						v.CFrame == v.CFrame * CFrame.new(0,0,-400)
					}
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal)
					tween:Play()
				end
			end
		end

Oh I know the problem, you don’t need to say v.Size inside of the goal. Instead, just say the Size and CFrame part. Try this:

for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal =  {
						Size.Z == Vector3.FromAxis(Enum.Axis.Z,800)	,
					       CFrame == v.CFrame * CFrame.new(0,0,-400)
					}
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal) --the first parameter is v so you don't include that in the goal.
					tween:Play()
				end
			end
		end


But now Size is an unkown global

I’m sorry I don’t know much about Vector3.FromAxis so I don’t think I can help you much. Good luck with your problem!

Alright then, i’ll revert to what I have since it’s only a minor effect

you have to have on = in the goal table and you can’t set a X, Y or Z value, because they are read only.

for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal =  {
						v.Size = Vector3.new(v.Size.X, v.Size.Y, 800)
					}		
					goal.CFrame = v.CFrame * CFrame.new(0,0,-400)
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal)
					tween:Play()
				end
			end
		end

Size.Z is a locked datatype that can’t be tweened. Vector3 already has a Z parameter, so you can try tweening the size to a new Vector3 with a smaller/larger Z parameter.

		for i, v in pairs(Folder:GetChildren()) do
			if v.Name == "Source" == false then
				if v.Name ~= "Inner" and v.Name ~= "Outter" and v.Name ~= "Wave" and v.Name ~= "Wave2" then
					local goal =  {
						v.Size = Vector3.new(v.Size.X, v.Size.Y, 800)
					}		
					goal.CFrame = v.CFrame * CFrame.new(0,0,-400)
					local info = TweenInfo.new(6)
					local tween = TweenService:Create(v,info,goal)
					tween:Play()
				end
			end
		end

And don’t worry about the size changing when it’s facing a another direction. A part’s size is only local to the part itself.

@NamphaTheGreat @Bliksem18
When i do these code, I’m still getting ‘unable to cast to dictionary’

on what line do you get the error?

this part

local tween = TweenService:Create(v,info,goal)

I’m sorry. you have to say:

local goal =  {
	Size = Vector3.new(v.Size.X, v.Size.Y, 800)
}	

it works now, but is there any way to rapidly change the Y and X axis? The tween just locks them at their original size

You could pause the tween with tween:Pause(). then you can change the size and then resume the tween with tween:Play()