Im making a rolling system in my game im using a Scrolling Frame for it but i cant figure out how i would get the correct position of my item in the frame
this is the script
function self.Open(itemFolder : Folder, multipliers : {}?)
local item = events:WaitForChild("Roll"):InvokeServer(itemFolder, multipliers)
local randomPosition = math.random(50, 58)
local targetFrame
for i = 1,60 do
local frame = assets.Template:Clone()
frame.Parent = scrollingFrame
if i == randomPosition then
targetFrame = frame
self.InitItem(frame, itemFolder, item.name)
else
local randomItem = events:WaitForChild("Roll"):InvokeServer(itemFolder, multipliers)
self.InitItem(frame, itemFolder, randomItem.name)
end
frame.Name = i
end
local position = self.calculatePosition(targetFrame)
local canvasPositon = Vector2.new(position, 0)
print(item.name)
print(canvasPositon)
local info = TweenInfo.new(10, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local tween = tweenService:Create(scrollingFrame, info, {CanvasPosition = canvasPositon})
tween:Play()
end
function self.calculatePosition(targetItem: Frame)
local itemCanvasX = targetItem.AbsolutePosition.X - scrollingFrame.AbsolutePosition.X + scrollingFrame.CanvasPosition.X
return itemCanvasX
end
and self.calculation() isnt calculating correctly
does anybody know any fixes?