Hello there, pretty much, I want to make a shutter which slides down and down only. When I change the size, it goes all weird and uneven. And I know that you have to change the position, but I can’t be bothered changing the position for every single part.
I was wondering if there was a more efficient way to do this, help would be appreciated.
I’ve tried this script and it does move the part in the current position, but it makes the Y value 0.001. My script is down below
local function CreateResizeTween(instance, tweenInfo, normalId, deltaAmount)
local delta = Vector3.FromNormalId(normalId) * deltaAmount
return TweenService:Create(instance, tweenInfo, { Size = script.Parent.Size + delta, Position = script.Parent.Position + delta / 2 }):Play()
end
CreateResizeTween(script.Parent, TweenInfo.new(5), Enum.NormalId.Bottom, -5)
I get that this works, but as stated in my original post, when you do try do something like this all it does is make the part size expand in both ways. I only want it to go down in one direction.
Are there other scripts which change the size of the curtain as well?
You can find places where its Size is changed by pressing CTRL/CMD + Shift + F, then typing the variable name used to reference the part in the script (typing Size in the search bar would help).
Think this should be 5, in this case you would be subtracting from the bottom instead of adding. Since your part’s Y size is smaller than 5 it would result in it becoming a negative which would clamp at 0.001.
There are other scripts that use TweenService that changes sizes in the game, but I don’t really think it’s the cause. If so, I’ll open up a temporary baseplate and see.
Yes, I’ve changed that after I posted the script, it still goes 0.001.
Edit: Still the same result in the different baseplate, can you show me how you’ve done your script that could be different from mine? Also I forgot to mention, when I did -5, the part expands upwards which is the opposite direction of what I want.
Oh I see, maybe it’s because Vector3.fromNormalId(bottom) is in the -Y direction so you would probably have to separate delta size from position. So for each axis of the vector we can just use math.abs on it. However, we also have to handle the case where deltaAmount is less than 0 to resize negatively, we could do this by just multiplying the deltaSize by math.sign(deltaAmount)
So something like:
local function CreateResizeTween(instance, tweenInfo, normalId, deltaAmount)
local deltaSize = Vector3.fromNormalId(normalId) * deltaAmount
deltaSize = Vector3.new(math.abs(deltaSize.X), math.abs(deltaSize.Y), math.abs(deltaSize.Z)) * math.sign(deltaAmount) -- if deltaAmount is less than 0 it will reduce the size, else it will increase the size
local deltaPosition = Vector3.fromNormalId(normalId) * deltaAmount
return tweenService:Create(instance, tweenInfo, {Position = instance.Position + deltaPosition / 2; Size = instance.Size + deltaSize})
end
if you are trying to do something like this then the below tween should work
what you do is set a part to the size and position you want your part to tween to then tween size and cframe to that part
local part1 = workspace.Part1
local part2 = workspace.Part2
local Tween = game.TweenService:Create(part1,TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{CFrame = part2.CFrame, Size = part2.Size})
Tween:Play()
Hello, thank you so much, your code does indeed work but I’ve comprised your code with @GreatPanda3 code so it’s a bit more shorter.
For people who want the code to help with their problem:
local TweenService = game:GetService("TweenService")
function CreateResizeTween(instance, tweenInfo, normalId, deltaAmount)
local delta = Vector3.fromNormalId(normalId) * deltaAmount
delta = Vector3.new(math.abs(delta.X), math.abs(delta.Y), math.abs(delta.Z)) * math.sign(deltaAmount) -- if deltaAmount is less than 0 it will reduce the size, else it will increase the size
TweenService:Create(instance, tweenInfo, {Position = instance.Position - delta / 2, Size = instance.Size + delta}):Play()
end
CreateResizeTween(script.Parent, TweenInfo.new(5), Enum.NormalId.Bottom, 8.5)
@Nyonic Hey, I can see that your code does work but that method is kind of what I wanted to avoid, individually setting the position and size for each part. But thanks for being kind enough to provide a solution.