I want the part to tween its size in one direction only
RIght now when I tween both side stretches instead of one
I’ve tried messing around with sin cos setting cframe stuff but none of them works (I’m using it wrong)
This is my code
local children = workspace:GetChildren()
local TweenService = game:GetService("TweenService")
local TweenIns, TweenOuts = {}, {}
local OutVector = Vector3.new(3, 0, 0)
local InVector = Vector3.new(30, 0, 0)
local orientation = 30
for _, child in ipairs(children) do
if child.Name == "SpawnLocation" then
table.insert(
TweenOuts,
TweenService:Create(child, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {
Size = child.Size + OutVector,
})
)
table.insert(
TweenIns,
TweenService:Create(child, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {
Size = child.Size + InVector,
})
)
end
end
while true do
for _, t in ipairs(TweenIns) do
t:Play()
end
task.wait(1)
for _, t in ipairs(TweenOuts) do
t:Play()
end
task.wait(1)
end
this is just how physics naturally work when you change the size of something; there is equal friction on both sides so the part has no forces making it slide towards one direction. to make the part forcefully move in one direction, you would need to see at every RunService.Heartbeat frame how much the part has stretched (in this direction):
and then teleport it accordingly so that one side doesnt move.
i remember ToObjectSpace existing for CFrames that teleports parts relative to itself so that it ignores the rotation (what you want in this case) try implementing this with CFrame manipulation and then setting the CFrame which will just teleport it without changing any rotation.
local children = workspace:GetChildren()
local TweenService = game:GetService("TweenService")
local TweenIns, TweenOuts = {}, {}
local OutVector = Vector3.new(3, 0, 0)
local InVector = Vector3.new(30, 0, 0)
local orientation = 30
for _, child in ipairs(children) do
if child.Name == "SpawnLocation" then
table.insert(
TweenOuts,
TweenService:Create(child, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {
Size = child.Size + OutVector,
Position = child.Position + OutVector,
})
)
table.insert(
TweenIns,
TweenService:Create(child, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.In), {
Size = child.Size + InVector,
Position = child.Position + InVector,
})
)
end
end
while true do
for _, t in ipairs(TweenIns) do
t:Play()
end
task.wait(1)
for _, t in ipairs(TweenOuts) do
t:Play()
end
task.wait(1)
end
You need to add the position argument to your code, this will forcefully move it in the direction giving if the effect that the size is changing in 1 direction.