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
I know I am a little late to answer but this is probably what you are looking for...
local originalSize = part.Parent.Parent.StatusBar.Status.Size.X part.Parent.Parent.StatusBar.Status.Size = Vector3.new(adjust, 0.45, 0.07) -- Set the size of the part part.Parent.Parent.StatusBar.Status.CFrame = part.Parent.Parent.StatusBar.Status.CFrame*CFrame.new(adjust/2-originalSize/2, 0, 0) -- Offset the bar by half of the size to move it from it's center to the side.
Edit: Example of what I mean in my comment:
local originalSize = part.Parent.Parent.StatusBar.Status.Size.X part.Parent.Parent.StatusBar.Status.Size = Vector3.new(adjust, 0.45, 0.07) -- Set the size of the part part.Parent.Parent.StatusBar.Status.CFrame = part.Parent.Parent.StatusBar.Status.CFrame*CFrame.new(-(adjust/2-originalSize/2), 0, 0) -- Offset the bar by half of the size to move it from it's center to the side.
Basically what it does is offset the bar from the center so that it stays in the same location as it started from. You can adjust the CFrame.new values which will change the relative offset to it's position and rotation. Z is backward so negative z is going in the direction the front face is facing, y is up and down so positive y is up and negative y is down, and x is left and right (I don't remember which is negative/positive but you can do some testing if you want to know).
Edit 2: Try this because it seems like it's because of the order of the properties being set and the variables being used:
part.Parent.Parent.StatusBar.Status.CFrame*CFrame.new(part.Parent.Parent.StatusBar.Status.Size.X/2, 0, 0) -- Offset the bar at the start to try and avoid bouncyness part.Parent.Parent.StatusBar.Status.Size = Vector3.new(adjust, 0.45, 0.07) -- Set the size of the part part.Parent.Parent.StatusBar.Status.CFrame = part.Parent.Parent.StatusBar.Status.CFrame*CFrame.new(-adjust/2, 0, 0) -- Offset the bar by half of the size to move it from it's center to the side.
idk what adjust is but lets say adjust is 5 and we want the bar change size
adjust = 5 script.Parent.Size = Vector3.new(adjust,1,1) script.Parent.CFrame = script.Parent.CFrame * CFrame.new(-adjust - 3,0,0) -- Negative or positive, test this on a basic part