local btn = script.Parent
btn.Parent.Contents.Position =
UDim2.new(
btn.Parent.Contents.posMoved.xScale.Value,
btn.Parent.Contents.posMoved.xOffset.Value,
btn.Parent.Contents.posMoved.yScale.Value,
btn.Parent.Contents.posMoved.yOffset.Value
}
I created StringValues with names corresponding to Scale and Offset X and Y values, which are children of a Configuration object named posMoved, then assigned those values to their according parameters in UDim2.new(). When I test my script, the Frame named Contents moves to the default {0,0,0,0} instead of 0.063, 0.02, 0.366, 0.05.
I did not know how to get the correct position values to be assigned after a few tweaks with tonumber() and curly brackets, so I instead I compiled the values of posMoved into one StringValue, named UDim2Position, then used string.split() which created a table of strings split from the provided one, and I set each parameter as a key.
local btn = script.Parent
btn.Parent.Contents.Position =
UDim2.new{
btn.Parent.Contents.posMoved.UDim2Position.Value:split(", ")[1],
btn.Parent.Contents.posMoved.UDim2Position.Value:split(", ")[2],
btn.Parent.Contents.posMoved.UDim2Position.Value:split(", ")[3],
btn.Parent.Contents.posMoved.UDim2Position.Value:split(", ")[4]
}
This method still results in Contents' position as {0,0,0,0} when set, but when I tried both methods on one different Frame, they worked, but not on the rest of the Frames I'm working with. I don't know why. Help is appreciated.
