Gui tweening doesn't work

I have a simple localscript that tweens a gui down and creates seperate textlabels for each person who survived the current round, then deletes those labels and tweens it back out of sight, my game is a round based game and i have used remoteevents to fire to all clients, the problem here is that the tween never starts and the whole script stops without giving an error
LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RemoteFolder = ReplicatedStorage:FindFirstChild("Remotes")
local SurvivorRemote = RemoteFolder:FindFirstChild("Survivors")
local Gui = script.Parent
local MainFrame = Gui.MainFrame
local SurvivorList = MainFrame.SurvivorList
local GuiLabel = MainFrame.TextLabel
local oldtext = GuiLabel.Text

SurvivorRemote.OnClientEvent:Connect(function(PlayerList)
	print("A")
	MainFrame.Visible = true
	local LableList = {}
	if #PlayerList > 0 then
		print("B1")
		for i,v in ipairs(PlayerList) do
			local Label = Instance.new("TextLabel",SurvivorList)
			Label.BackgroundTransparency = 1
			Label.TextScaled = true
			Label.Text = v
			table.insert(LableList,Label)
		end
	else
		print("B2")
		GuiLabel.Text = "Noone Survived!"
	end
	local Tweeninfo = TweenInfo.new(2,Enum.EasingStyle.Back,Enum.EasingDirection.InOut)
	local goal = {
		["Position"] = UDim2.new(0.295,0,0.05,0)
	}
	local Tween = TweenService:Create(MainFrame,Tweeninfo,goal)
	Tween:Play()
	Tween.Completed:Wait()
	wait(5)
	local goal = {
		["Position"] = UDim2.new(0.295,0,-2.05,0)
	}
	local Tween = TweenService:Create(MainFrame,Tweeninfo,goal)
	Tween:Play()
	Tween.Completed:Wait()
	MainFrame.Visible = false
	if #PlayerList > 0 then
		print('C1')
		for i,v in ipairs(LableList) do
			table.remove(LableList,i)
			v:Destroy()
		end
	else
		print('C2')
		GuiLabel.Text = oldtext
	end
end)

as you can see, i have added print() statements in each conditional statement to debug the script and the script stops after printing either B1 or B2 in the output, the tween doesn’t work and the script stops, I can’t find a solution to this problem or what is causing it so I decided to post this problem here, any help is appreciated.

1 Like

Sorry lol, could you format your script using ``` before and after the script (so it’s easier for us to read)

1 Like

I have formatted the script as you requested

I think I found the error. whenever you make the goal table, instead of saying ["Position"], make it just say Position = UDim2.new() (and fill in the udim2 value)

I will try it and reply if this fixes it

1 Like

Nope, the result is still the same, script gets stuck

Oh wait, I think the MainFrame variable just hasn’t loaded since you didn’t use :WaitForChild(). At the top where you list your variables, make sure to use that to ensure that they aren’t nil.

As seen here:

local Gui = script.Parent
local MainFrame = Gui:WaitForChild("MainFrame")
local SurvivorList = MainFrame:WaitForChild("SurvivorList")
local GuiLabel = MainFrame:WaitForChild("TextLabel")
local oldtext = GuiLabel.Text

ok, I will try that, if it works, i will mark this as the solution, however, this seems unlikely as if this was the case, the script would error when it tried to set a nil value’s visible to true, it does not error

You cannot use TweenService to tween GuiObjects.
See GuiObject:TweenSize and GuiObject:TweenPosition instead

weird I have never seen anybody tweening guis like that, we are using :TweenPosition() or :TweenSize() for those purposes

Yes, it seems I was right, the problem still persists

You can use either for GuiObjects

I have made a game loading gui previously that used tweenservice and it worked correctly, I know about TweenSize and TweenPosition but I will try those nonetheless

Are there any errors in output? If so, screenshot/copy them here

And along with that, are your print debuggers actually printing anything?

No errors, which is why i posted the problem here, it seems to be a problem in the tweening part of the code.
But the script does indeed print B2 or B1 depending on the conditional statement but stops after that

While I appreciate you trying to help me, it seems you are making the same mistake I made before I read this article, it seems you don’t truly understand when to use :WaitForChild(), I would recommend reading this article as it explains the common mistakes most devs make when using this function:

Personally I dont put the

["Position"]

Have you tried taking it out and just doing

Position = Udim2.new()

Thats what I personally do.

Yes, I have tried that but still it doesn’t work.

How long did you wait for the script to work name a time.

1 Like

Rounds in my game start after 60 seconds, take a further 15 seconds and then end after 90 seconds, the gui is supposed to show after a round has ended, waited so long another round started