displaying a piano, how would i calculate where to place the black keys?
i made a piano that expands across the screen, the white keys and sizing of the black keys is working as expected, there is a folder in the same parent of the script called Piano, this is where the frames of the keys are stored, but as any piano looks, black keys are placed weirdly, how would i calculate the position of the black keys on the screen (Scale or Offset or both propertys of a udim2 can be used):
01 | script.Parent.DrawPiano.Event:connect( function (octaves) |
02 | local whitekeys = 7 *octaves |
03 | local blackkeys = 5 *octaves |
04 | for i = 1 ,whitekeys, 1 do |
05 | local key = Instance.new( "Frame" , script.Parent.Piano) |
08 | script.Parent.AbsoluteSize.X/whitekeys, |
12 | key.Position = UDim 2. new( |
18 | key.BackgroundColor 3 = Color 3. new( 1 , 1 , 1 ) |
19 | key.BorderColor 3 = Color 3. new( 0.67 , 0.67 , 0.67 ) |
20 | key.BorderSizePixel = 2 |
24 | for i = 1 ,blackkeys, 1 do |
25 | local key = Instance.new( "Frame" , script.Parent.Piano) |
32 | key.Position = UDim 2. new( |
38 | key.BackgroundColor 3 = Color 3. new( 0.2 , 0.2 , 0.2 ) |
39 | key.BorderColor 3 = Color 3. new( 0 , 0 , 0 ) |
40 | key.BorderSizePixel = 2 |