My brain is melting. I think there’s something wrong with me or the Roblox engine.
So, here we have a UI, I want to tween every red frame of the UI: up and down. To move them in those directions, I of course made main frames move (they are not transparent) and visualized frames (they are transparent), so I could get custom positions without changing any values in the code.
The frames (from left to right) that are red and not transparent are “First”, “Middle” and “Second”.
And after the UI marking, the fun begins in the coding process (code parts that need my and your investigation are marked with comments):
repeat
wait()
until game:IsLoaded()
local TS = game.TweenService
local Player = game.Players.LocalPlayer
local PlayerGUI = Player.PlayerGui
local UI = PlayerGUI:WaitForChild("Loading")
local Back = UI.Back -- The frame which is on the background, of course.
local Middle, First, Second = Back.Middle, Back.First, Back.Second -- Non-transparent frames.
local MiddlesFolder, FirstFolder, SecondFolder = Middle.ExpectionPositions, First.ExpectionPositions, Second.ExpectionPositions -- Folders inside each frame, folder have transparent frames: "Up" and "Down"
-- Tables for having visualized positioning for frames
local Positions = {
MiddlePhases = {
UP = MiddlesFolder.Up,
DOWN = MiddlesFolder.Down
};
FirstPhases = {
UP = FirstFolder.Up,
DOWN = FirstFolder.Down
};
SecondPhases = {
UP = SecondFolder.Up,
DOWN = SecondFolder.Down
};
}
-- Check if tables does exist after creating
for _, tab in pairs(Positions) do
if tab then
print("Gotten "..tostring(tab))
elseif tab == nil then
error("Table was not created, maybe.")
end
end
-- Function to loop the tweening
function moveFrame(frame, phases)
if phases == nil then
print("Could not get the table :(")
return
end
local currentPositionIndex = 1
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
while true do
local currentPhase = phases[currentPositionIndex]
print("Inspecting "..tostring(phases)) -- Table itself shows the special id,
print("Checking phase: "..tostring(currentPhase)) -- value from table gives nil.
local goal = {
Position = UDim2.new(currentPhase.X.Scale, currentPhase.X.Offset, currentPhase.Y.Scale, currentPhase.Y.Offset) -- Here, when it tries to get first value from table - it says that the returned value was nil.
}
print("Setting goal to: "..tostring(frame))
local tween = TS:Create(frame, tweenInfo, goal)
tween:Play()
print("Playing Tween of frame: "..tostring(frame))
tween.Completed:Wait()
print("Finished Tween of frame: "..tostring(frame))
currentPositionIndex = currentPositionIndex % #phases + 1
end
end
local Coroutine1, Coroutine2, Coroutine3 = coroutine.create(moveFrame(Middle, Positions.MiddlePhases)), coroutine.create(moveFrame(First, Positions.FirstPhases)), coroutine.create(moveFrame(Second, Positions.SecondPhases))
coroutine.resume(Coroutine1)
coroutine.resume(Coroutine2)
coroutine.resume(Coroutine3)
The result of running this code leads me to such output:
I honestly don’t know why table gives the id when print, but after another check if table has value from an index. I need a little bit of assistance.