Tweening multiple things isnt working

local function nextQuestion()
	for i, answer in ipairs(answersContainer:GetChildren()) do
		if answer:IsA("Frame") then
			if answer.Transparency ~= 0 then
				answer.Transparency = 0
			end
			if answer.letterContainer.Transparency ~= 0 then
				answer.letterContainer.Transparency = 0
			end
			if answer.letterContainer.letter.TextTransparency ~= 0 then
				answer.letterContainer.letter.TextTransparency = 0
			end
		end
	end
	currentQuestion += 1
	if currentQuestion > 1 then
		for i, question in ipairs(answersContainer:GetChildren()) do
			if question:IsA("Frame") then
				local outTween = tweenService:Create(question,info1,changePositionGoal)
				outTween:Play()
			end
		end
	end
	wait(0.25)

This is a segment of my code. Before, I had a frame tweening off the screen and it worked fine, however when i do it to multiple things like above it doesnt tween but the code still runs below it. How can i make this tween work for all 3 frames?

What is is your tweenInfo, also, is changePositionGoal a table with a value like:

{Position = Udim2.new(2,0,0,0)}

or something like that?

Two quick notes to follow then:
You can shorten your code by changing:

local outTween = tweenService:Create(question,info1,changePositionGoal)
outTween:Play()

to:

tweenService:Create(question,info1,changePositionGoal):Play()

Also, they are GUIObject's, so you can use :TweenPosition(), which is a much more simple solution.

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenPosition

sorry for late response, here are those


local info1 = TweenInfo.new(
   0.5,
   Enum.EasingStyle.Linear,
   Enum.EasingDirection.Out,
   0,
   true,
   0
   
)

local changePositionGoal = {
   Position = UDim2.fromScale(0.502,1.5)
}

To deduce where the problem lies, put a print statement just before the tween runs and see if you get any output. If you don’t, then it’s probably a problem with your for loop.

when i put it before the tween it works, andwhen i put one after it it works too

Ok, then the issue is probably your tween. I would honestly just suggest switching it to question:TweenPosition(Udim2.fromScale(0.502,1.5)), that should work, or something like that, I haven’t used the function in a while, here’s the devHub page:
https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenPosition

still doesnt tween, just prints

What else is happening to those frames, at some point in the script is this happening to them:

question.Visible = false

If that is happening, it may just be that it’s occuring before they have time to tween, so they just disappear. The nice thing with TweenPosition is that you can set a callback function. So I usually do this:

question:TweenPosition(Udim2.fromScale(0.502,1.5), Enum.EasingDirection.Linear, Enum.EasingStyle.Out, 0.5, false, function()
    question.Visible = false
end)
chosenQuestions = 0
chosenQuestionsList = {}
while chosenQuestions < 10 do
	questionChosenNumber = math.random(1,#questions)
	questionChosen = questions[questionChosenNumber]
	table.remove(questions, questionChosenNumber)
	table.insert(chosenQuestionsList,questionChosen)
	chosenQuestions += 1
end
print(chosenQuestionsList)
local player = game.Players.LocalPlayer
local questionMainFrame = script.Parent.Question.container
local skipInterviewFrame = script.Parent["Skip Interview"].skipInterview
local answersContainer = questionMainFrame.answerContainer
local questionFrame = questionMainFrame.question
local skipInterviewButton = skipInterviewFrame.detect
local replicatedStorage = game.ReplicatedStorage
local remotes = replicatedStorage.Remotes
local remoteEvent = remotes.RemoteEvent
local remoteFunction = remotes.RemoteFunction
local tweenService = game:GetService("TweenService")

local info1 = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	true,
	0
	
)

local changePositionGoal = {
	Position = UDim2.fromScale(0.502,1.5)
}

local outTween = tweenService:Create(questionMainFrame,info1,changePositionGoal)

local questionLabel = questionFrame["question container"].question
local answerA = answersContainer.answerboxA.answer
local aDetect = answerA.Parent.detect
local answerB = answersContainer.answerboxB.answer
local bDetect = answerB.Parent.detect
local answerC = answersContainer.answerboxC.answer
local cDetect = answerC.Parent.detect
local currentQuestion = 0
local UserAnswers = {}

local function finishApplication()
	print("Application finished")
	remoteEvent:FireServer(chosenQuestionsList,UserAnswers)
	wait(1)
	questionLabel.Text = game.Lighting.FinishText.Value
	answerA.answer.Text = ""
	answerB.answer.Text = ""
	answerC.answer.Text = ""
	print(UserAnswers)
end

local function nextQuestion()
	for i, answer in ipairs(answersContainer:GetChildren()) do
		if answer:IsA("Frame") then
			if answer.Transparency ~= 0 then
				answer.Transparency = 0
			end
			if answer.letterContainer.Transparency ~= 0 then
				answer.letterContainer.Transparency = 0
			end
			if answer.letterContainer.letter.TextTransparency ~= 0 then
				answer.letterContainer.letter.TextTransparency = 0
			end
		end
	end
	currentQuestion += 1
	if currentQuestion > 1 then
		for i, question in ipairs(answersContainer:GetChildren()) do
			if question:IsA("Frame") then
				print("Hello")
				question:TweenPosition(UDim2.fromScale(0.502,1.5))
				print("Hi")
			end
		end
	end
	wait(0.25)
	if currentQuestion == #chosenQuestionsList + 1 then
		finishApplication()
		return
	end
	
	local currentQuestionArray = chosenQuestionsList[currentQuestion]
	
	local question = currentQuestionArray[1]
	local answer1 = currentQuestionArray[2]
	local answer2 = currentQuestionArray[3]
	local answer3 = currentQuestionArray[4]
	local correctAnswer = currentQuestionArray[currentQuestionArray[5] + 1]
	
	questionLabel.Text = question
	answerA.Text = answer1
	answerB.Text = answer2
	answerC.Text = answer3
	
	for i, answer in ipairs(answersContainer:GetChildren()) do
		for j, text in ipairs(answer:GetChildren()) do
			if text:IsA("TextLabel") then
				if text.Text == " " then
					answer.Transparency = 1
					answer.letterContainer.Transparency = 1
					answer.letterContainer.letter.TextTransparency = 1
				end
			end
		end
	end
end

local function setup()
	nextQuestion()
	
	for i = 1, #answersContainer:GetChildren() do
		local child = answersContainer:GetChildren()[i]
		if child:IsA("Frame") then
			child.detect.MouseButton1Click:Connect(function()
				table.insert(UserAnswers,child.AnswerNumber.Value)
				nextQuestion()
			end)
		end
	end
end

setup()

here is full code, if the answer is " " which i have as a placeholder, the frame dissapears for that question

1 Like

Fix the TweenPosition, change it to the code I gave you, and see if it works then. As you have it currently, it won’t work.

Sorry for the late response, I had lots of school work going on. I updated the code and all that happened was they dissapeared when i answered