GUIs not tweening after player respawn

So the GUIs only play the first time the player spawn. After the player died, the GUIs don’t tween even though the CharacterAdded event fired and the script inside the event still run.

Here is the script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local bestScore = script.Parent.BestScore
local playButton = script.Parent.PlayButton

local remoteEventsFolder = ReplicatedStorage:WaitForChild("RemoteEventsFolder")
local bindableEventsFolder = ReplicatedStorage:WaitForChild("BindableEventsFolder")

local TWEEN_TIME = 2
local openPos1 = UDim2.new(0.5, 0, 0.1, 0) --For "BestScore"
local openPos2 = UDim2.new(0.5, 0, 0.4, 0) --For "PlayButton"
local closePos1 = UDim2.new(0.5, 0, 2, 0) --For "BestScore"
local closePos2 = UDim2.new(0.5, 0, 2, 0) --For "PlayButton"

remoteEventsFolder.CharacterAdded.OnClientEvent:Connect(function(player)
	print("Character Added")
	bestScore:TweenPosition(openPos1, Enum.EasingDirection.Out, Enum.EasingStyle.Back, TWEEN_TIME)
	playButton:TweenPosition(openPos2, Enum.EasingDirection.Out, Enum.EasingStyle.Back, TWEEN_TIME)
end)

local function closeGui()
	bestScore:TweenPosition(closePos1, Enum.EasingDirection.In, Enum.EasingStyle.Back, TWEEN_TIME)
	playButton:TweenPosition(closePos2, Enum.EasingDirection.In, Enum.EasingStyle.Back, TWEEN_TIME)
end

playButton.Activated:Connect(function()
	closeGui()
	bindableEventsFolder.StartGuisClosed:Fire()
	remoteEventsFolder.PlayButtonClicked:FireServer()
end)

Here is the video:
Laser Jump - Roblox Studio 2021-12-05 14-16-18.zip (8.2 MB)

In the output window, it still print “Character Added” on the second time ==> The event still fires, but the GUIs don’t tween.

1 Like

I assume this script is located in the StarterGui? While I can see the logic behind this, there’s a much simpler way to go about this.

For Example:

You can handle the button presses and closing from different scripts.

StarterGui moves the GUI to PlayerGui after the player joins the game

His issue can be solved using

1 Like

Well yes, but if he tweens a GUI in StarterGui, the changes will not be shown on the screen.

So I should set ResetOnSpawn property of the ScreenGui to false, right?

Yay! It worked, the GUIs now tweening properly! Thanks a lot!