I need help with tweening

I have been trying to tween a gui so it goes in the screen for a few seconds then goes out again.
the thing is, my tween simply doesn’t work… It just teleports the gui where it is supposed to go and doesn’t tween it.

Here is my script:

local CurrentRegion = script.Parent.CurrentRegion
local Text = script.Parent.PlaceName

CurrentRegion.Changed:Connect(function()
	Text.Visible = true
	Text.Text = CurrentRegion.Value
	Text:TweenPosition(
		UDim2.new(0.5,0,0.2,0),
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Exponential,
		1
	)
	wait(#CurrentRegion.Value / 4 + 2)
	Text:TweenPosition(
		UDim2.new(0.5,0,0,0),
		Enum.EasingDirection.In,
		Enum.EasingStyle.Exponential,
		1
	)
	Text.Visible = false
end)

Please help

First of all,

local goal = {}
goal.Position = UDim2.new(0.5, 0, 0, 0)
 
local tweenInfo = TweenInfo.new(1, -- the time it takes for the tween
	Enum.EasingDirection.In,
	Enum.EasingStyle.Exponential,
)
 
local tween = TweenService:Create(part, tweenInfo, goal)

is better in my opinion.
The problem is that the two tweens are conflicting, use the method above with

-- the "tween" var is the tween's variable
tween.Completed:Wait()

in between

Ex:

local CurrentRegion = script.Parent.CurrentRegion
local Text = script.Parent.PlaceName

CurrentRegion.Changed:Connect(function()
	Text.Visible = true
	Text.Text = CurrentRegion.Value
	local goal = {}
	goal.Position = UDim2.new(0.5, 0, .2, 0)

	local tweenInfo = TweenInfo.new(1,
		Enum.EasingDirection.Out,
		Enum.EasingStyle.Exponential,
	)
	local tween = TweenService:Create(Text, tweenInfo, goal)


	tween.Completed:Wait()

	goal.Position = UDim2.new(0.5, 0, 0, 0)

	local tweenInfo = TweenInfo.new(1,
		Enum.EasingDirection.In,
		Enum.EasingStyle.Exponential,
	)
	local tween = TweenService:Create(Text, tweenInfo, goal)

	Text.Visible = false
end)

This should work.

1 Like

Thank you so much !!
Here is the version I will be using:

local CurrentRegion = script.Parent.CurrentRegion
local Text = script.Parent.PlaceName

local TweenService = game:GetService("TweenService")

CurrentRegion.Changed:Connect(function()
	Text.Visible = true
	Text.Text = CurrentRegion.Value
	local goal = {}
	goal.Position = UDim2.new(0.5, 0, .2, 0)

	local tweenInfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Exponential,
		Enum.EasingDirection.Out
	)
	local tween = TweenService:Create(Text, tweenInfo, goal)
	tween:Play()

	tween.Completed:Wait()
	
	wait(#CurrentRegion.Value * 0.1 + 2)

	goal.Position = UDim2.new(0.5, 0, 0, 0)

	local tweenInfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Exponential,
		Enum.EasingDirection.In
	)
	local tween = TweenService:Create(Text, tweenInfo, goal)
	tween:Play()
	
	tween.Completed:Wait()
	Text.Visible = false
end)
1 Like

Great! If it helped, please mark the post as the answer, so other people with the same question can find it.

1 Like

Quick question, why is there a #? isn’t CurrentRegion a intvalue or something?

no it is a string value that says where the player curently is.
this script detects a change in that and anounces it to the player.

So i wait long enough for the player to read