3D Bar not functioning as inteded

I am making an indicator which is 3D that tells you what a value is at via bar, however I am failing to make it reposition correctly and it makes it just completely get high distance from the indicator box.

value = workspace.States.Power
max = 100
oldz = script.Parent.Flash.Position.Z
oldx = script.Parent.Flash.Size.X 
	local test = (max / value.Value)
	local test2 = tonumber("-"..test.."")
	script.Parent.Flash.Size = Vector3.new((oldx / test),script.Parent.Flash.Size.Y,script.Parent.Flash.Size.Z)
	script.Parent.Flash.Position = Vector3.new(script.Parent.Flash.Position.X,script.Parent.Flash.Position.Y,oldz / test2)

Sizing works normally, however the positioning does not.

I’m guessing you’re resizing the part on the X axis and moving it along the Z axis, right?

If so, here’s how I’d do it:

local value = workspace.States.Power
local part = script.Parent.Flash

local initSize = part.Size

local bottom = part.CFrame * CFrame.new(0, 0, -part.Size.X / 2) -- this will be the sort of "anchor"
local max = 100
    local newSizeZ = max / value.Value

    part.Size = Vector3.new(initSize.X / percentage, part.Size.Y, part.Size.Z)
    part.CFrame = bottom * CFrame.new(0, 0, part.Size.X / 2)
1 Like

I would want to see an image of it since it’s graphic related.

The intent is that a value, (NumberValue) controls this bar.

Decided to do a 2D one with a BillboardGUI instead.