So like the title says i need to tween something in a certain direction, which is upwards in this case. The size does tween properly as i need it to but i have no idea how to make it go upwards only, instead of that it goes both upwards and downwards so the hand of the character which should be at the bottom of the enlarged object is actually in the middle. Here's the script, first tween is the one i need to go in a certain direction.
wait() script.Parent.OnServerEvent:Connect(function(player,tool) local sword = tool.SwordMesh local handle = tool.Handle local blade = tool.Blade local weld = handle.Weld local TweenService = game:GetService("TweenService") local TweenInform1 = TweenInfo.new( 1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0 ) local properties = { Size = Vector3.new(56,75,9); Transparency = 0; } local Tween = TweenService:Create(sword,TweenInform1,properties) Tween:Play() local TweenInform3 = TweenInfo.new( 1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0 ) local properties3 = { Size = Vector3.new(100,10,10.6); Transparency = 1; } local Tween3 = TweenService:Create(blade,TweenInform3,properties3) Tween3:Play() end)
tWhen you resize a Part, it will shrink its size from x(left and right), y(upwards and downwards) and z(forwards and backwards) according to what you modify. For example, if I change the size of say Part from {1, 7, 1} to {1, 9, 1}, the difference in size is 2 studs in the y axis: up and down - 1 stud up, 1 stud down. If we want the Part to only change size upwards, then we need to position the Part upwards by 1 again because changing the size by 2 caused our Part to go 1 stud up & down!
In code, it might look like this
local myPart = workspace.Part myPart.Size = myPart.Size + Vector3.new(0, 2, 0) --adding 2 studs to the Part's current size --since i only want the Part to size upwards, we need to offset the part by Y / 2, or in our case, 1 myPart.Position = myPart.Position + Vector3.new(0, 1, 0)
For a Tweening example, it's the same thing. It might look something like this (example from something in your code)
local TweenInform3 = TweenInfo.new( Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0 ) local properties3 = { Size = blade.Size + Vector3.new(10, 10, 10); --here we are adding 10 studs in size in every direction Position = blade.Position + Vector3.new(0, 5, 0) --we need to add an offset of Y/2, or 5 in this case, because we need to add back the blade that went downwards as discussed previously! Transparency = 1; } local Tween3 = TweenService:Create(blade,TweenInform3,properties3) Tween3:Play()
You need to add Position to properties table . If you need the part to go upwards, while growing, it would equal half of the grow difference. For example your part original size was (16,25,3) and new size is (56,75,9) difference is (40,50,6). Then you take the middle value (for moving up and down) and divide by 2. In this case 25. That is how many studs you need to move part upwards. So your properties table will look like this:
local moveFactor = (75 - sword.Size.Y) / 2 local properties = { Size = Vector3.new(56,75,9); Transparency = 0; Position = sword.Position + Vector3.new(0,moveFactor,0) }