Tweens not playing after character respawns

I have a tween script for my gui and it’s supposed to play the tweens to show the buttons and images when the player respawns, but they don’t play.

Here is my script, it’s a local script inside starterplayerscripts

local tweenService = game:GetService("TweenService")

local player = game.Players.LocalPlayer
local orderText = player.PlayerGui:WaitForChild("Starter").Background.Main.Order
local playBttn = player.PlayerGui:WaitForChild("Starter").Background.Main.Play
local shopBttn = player.PlayerGui:WaitForChild("Starter").Background.Main.Shop
local rose = player.PlayerGui:WaitForChild("Starter").Background.Main.Order.rose

local orderInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local playInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local shopInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local roseInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)

local playGoal1 = {Position = UDim2.new(0.352, 0,0.401, 0)}	
local shopGoal1 = {Position = UDim2.new(0.352, 0,0.625, 0)}
local orderGoal1 = {TextTransparency = 0}
local roseGoal1 = {ImageTransparency = 0}

local playGoal2 = {TextTransparency = 1}
local shopGoal2 = {TextTransparency = 1}
local orderGoal2 = {TextTransparency = 1}
local roseGoal2 = {ImageTransparency = 1}

local orderTween1 = tweenService:Create(orderText, orderInfo, orderGoal1)
local orderTween2 = tweenService:Create(orderText, orderInfo, orderGoal2)
local roseTween1 = tweenService:Create(rose, roseInfo, roseGoal1)
local roseTween2 = tweenService:Create(rose, roseInfo, roseGoal2)
local playTween1 = tweenService:Create(playBttn, playInfo, playGoal1)
local playTween2 = tweenService:Create(playBttn, playInfo, playGoal2)
local shopTween1 = tweenService:Create(shopBttn, shopInfo, shopGoal1)
local shopTween2 = tweenService:Create(shopBttn, shopInfo, shopGoal2)

repeat wait() until player.Character:FindFirstChild("Humanoid") ~= nil
if player.Character:FindFirstChild("Char") == nil then
	print("cant find Char, playing tweens now")
	player.PlayerGui:WaitForChild("Starter").Background.Main.Visible = true
	print("main is visible")
	orderTween1:Play()
	print("Started order tween")
	roseTween1:Play()
	print("Started rose tween")
	task.wait(2.5)
	playTween1:Play()
print("started play tween")
	task.wait(.5)
	shopTween1:Play()
print("stared shop tween")
end

NOTE: none of the print statements print when they respawn

This script will ONLY run once when the player joins. You have to add a CharacterAdded connection.
This is due to the script being in starterplayer.

1 Like

Where would I add it? In place of this line?

Player.CharacterAdded:Connect(function(Character)
  print("cant find Char, playing tweens now")
	player.PlayerGui:WaitForChild("Starter").Background.Main.Visible = true
	print("main is visible")
	orderTween1:Play()
	print("Started order tween")
	roseTween1:Play()
	print("Started rose tween")
	task.wait(2.5)
	playTween1:Play()
print("started play tween")
	task.wait(.5)
	shopTween1:Play()
print("stared shop tween")
end)

Treat it as a server-script.

1 Like

Now it’s not tweening them at all

What exactly are you trying to do?

Play those tweens whenever a player’s character is added if they don’t have a value called “Char” inside of the character

there isnt a value that I add into the character called Char yet, but for some reason it’s not tweening and nothing prints

player.CharacterAdded:Connect(function(Character)
	if not Character:FindFirstChild("char") then --? 
		print("cant find Char, playing tweens now")
		player.PlayerGui:WaitForChild("Starter").Background.Main.Visible = true
		print("main is visible")
		orderTween1:Play()
		print("Started order tween")
		roseTween1:Play()
		print("Started rose tween")
		task.wait(2.5)
		playTween1:Play()
		print("started play tween")
		task.wait(.5)
		shopTween1:Play()
		print("stared shop tween")
	end
end)

Same issue, nothing prints and no tweens play, even when I remove this line

Then you might to have to resort startercharacter since those run everytime your character respawns.

I moved it to starter character scripts and it still has the same issue

Which print statement dose not print?

None of the print statements print

EDIT: I fixed it by removing the characteradded line

If nothing prints, then somebody is probably with your script, any infinite yields?

I fixed it by removing the character added line after moving it to starter character scripts

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.