I have this code:
part.Parent.Parent.StatusBar.Status.Size = Vector3.new(adjust, 0.45, 0.07)
And when I change the size of the status bar, it looks like the one on the left in this picture. https://gyazo.com/98227cac311248ffb70e1dc104ccb8a8 How do I determine the position so it looks like the one on the right and is always scaled on the part while it's moving? It may look like this when it's moving: https://gyazo.com/a98ad47562fbf1be048de087e271445b
EDIT: Whole Code
local length = 15
local current = 0
local barlength = 5.75
local adjust = current/length * barlength
local lastX = part.Parent.Parent.StatusBar.Status.Size.X
local originalSize = part.Parent.Parent.StatusBar.Status.Size.X
local function reAdjust()
adjust = current/length * barlength
end
local function size()
--part.Parent.Parent.StatusBar.Status.Size = Vector3.new(adjust, 0.45, 0.07)
tweenSite(part.Parent.Parent.StatusBar.Status, Vector3.new(adjust, 0.45, 0.07))
--part.Parent.Parent.StatusBar.Status.CFrame = part.Parent.Parent.StatusBar.Status.CFrame * CFrame.new(-adjust - 3,0,0)
part.Parent.Parent.StatusBar.Status.CFrame = part.Parent.Parent.StatusBar.Status.CFrame*CFrame.new(adjust/2-originalSize/2, 0, 0)
--part1.Position = otherPart.Position+(part1.Position/2)
--local differ = part.Parent.Parent.StatusBar.Status.Size.X - lastX
--differ = differ / 4
--part.Parent.Parent.StatusBar.Status.Position = part.Parent.Parent.StatusBar.Status.Position - Vector3.new(differ, 0, 0)
end
repeat
wait(.5)
if current <= length then
print(current)
current = current + .5
reAdjust()
size()
end
until current == length

9 comments
That made it go all the way to the other end. https://gyazo.com/4b6d06319857fdfe590016e20223c856 How could I make it STAY on the bar?
Do you mean the bar is going in the wrong direction? If that's what you can you can put the first argument of CFrame.new inside of some parentheses and make the whole thing negative so it offsets in the opposite direction.
No, the bar is going off of the little bar it's supposed to stay on. Look at the first little grey bar and look at the rest of the bars. In the end, that green is supposed to look like the other green parts.
Also if the bar is zooming away try resetting the position of the bar before you call the adjust code if you aren't doing it already. Otherwise let me know.
Ok, it works now. But, it doesn't look smooth and it's bouncy. How would I fix that? I made the position start to reset. https://gyazo.com/c9489c592cdd1ca24ec0704faba0959b
Try my second edit... My guess is that the size is getting set at the same time as the starting variable.
Oh I didn't see your full code yet but it wouldn't hurt to try that edit... It could be some weird Roblox physics thing too... I've had that issue once.
Edit 2 made it go backwards.
Then try making both of the cframe offsets negative like I said before... It's either the adjust one or them both so if it's slightly offset from it's starting position try making both negative instead of the one that uses adjust.