Textlabel won't open and tween after I click on the button

  1. What do you want to achieve? Keep it simple and clear!

Hi, so I’m trying to make a textlabel to open and tween after I click on the textbutton.

  1. What is the issue? Include screenshots / videos if possible!

the problem with my script is that it doesn’t open and tween and I got this error in the output.

TweenInfo.new first argument expects a number for time.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried researching on google and the developer forum for solutions but couldn’t seems to find a way through to fix my script.

local TweenService = game:GetService("TweenService")
local PlayerService = game:GetService('Players')
local Player = PlayerService.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')
local TextLabel = game.StarterGui.ScreenGui.TextButton.TextLabel
local TextButton = script.Parent.TextButton


ScreenGui.TextButton.MouseButton1Click:Connect(function()
	TextLabel.BackgroundTransparency = 0
	TextLabel.TextTransparency = 0
	local info = TweenInfo.new{
		15,
		Enum.EasingStyle.Sine, 
		Enum.EasingDirection.Out,
		0,
		false,
		0
	}

	local InfoPlay = TweenService:Create(TextLabel, info)

	InfoPlay:Play()
end)

I’d be appreciative if someone could help me with my script.

So to my understanding when someone clicks the ui it tweens to its position correct?

uh, no so when someone clicks the ui it opens up the textlabel then it will probably wait a few seconds before tweening…

btw, the textbutton visibility also becomes false after someone clicks on it.

is the position on where you want to go the textlabel? where do you want your text label to move to?

TweenService:Create requires 3 arguments: an instance, the TweenInfo, then a table of properties for the goal result.

Try this:

local properties = {
    ['BackgroundTransparency'] = 0;
    ['TextTransparency'] = 0;
}
local InfoPlay = TweenService:Create(TextLabel, info, properties)

InfoPlay:Play()

{0, 0},{0.457, 0}


{0.732, 0},{0.457, 0}

Or if you want the position to be specific then use a UDim2

(UDim2.new(0, 0, 0, 0)
1 Like

Yeah but then you’d have to add that position to the table of properties.

local properties = {
    ['Position'] = UDim2.new(0,0,0,0)
}
ScreenGui.TextButton.MouseButton1Click:Connect(function()
	TextLabel.BackgroundTransparency = 0
	TextLabel.TextTransparency = 0
	local info = TweenInfo.new{
		15,
		Enum.EasingStyle.Sine, 
		Enum.EasingDirection.Out,
		0,
		false,
		0
	}

	local properties = {
    	['Position'] = UDim2.new(0.732, 0, 0.457, 0)
	}

	local InfoPlay = TweenService:Create(TextLabel, info, properties)

	InfoPlay:Play()
end)

There, should work now

I got the same error TweenInfo.new first argument expects a number for time.

[‘Script’]

local TweenService = game:GetService("TweenService")
local PlayerService = game:GetService('Players')
local Player = PlayerService.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')
local TextLabel = game.StarterGui.ScreenGui.TextButton.TextLabel
local TextButton = script.Parent.TextButton

ScreenGui.TextButton.MouseButton1Click:Connect(function()
	TextLabel.BackgroundTransparency = 0
	TextLabel.TextTransparency = 0
	local info = TweenInfo.new{
		15,
		Enum.EasingStyle.Sine, 
		Enum.EasingDirection.Out,
		0,
		false,
		0
	}

	local properties = {
		['Position'] = UDim2.new(0.732, 0, 0.457, 0)
	}

	local InfoPlay = TweenService:Create(TextLabel, info, properties)

	InfoPlay:Play()
end)
local TweenService = game:GetService("TweenService")
local PlayerService = game:GetService('Players')
local Player = PlayerService.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')
local TextLabel = game.StarterGui.ScreenGui.TextButton.TextLabel
local TextButton = script.Parent.TextButton

ScreenGui.TextButton.MouseButton1Click:Connect(function()
	TextLabel.BackgroundTransparency = 0
	TextLabel.TextTransparency = 0
	local info = TweenInfo.new(
		15,
		Enum.EasingStyle.Sine, 
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)

	local properties = {
		['Position'] = UDim2.new(0.732, 0, 0.457, 0)
	}

	local InfoPlay = TweenService:Create(TextLabel, info, properties)

	InfoPlay:Play()
end)

Forgot to switch the curly brackets with parentheses

which line of code is it? its supposed to say right next to the error

I clicked on it but nothing shows up and theres no error

what is the current position of the text label

the error happen to be in line 12 TweenInfo.new first argument expects a number for time. - Client - LocalScript:12

is under ScreenGui and textbutton

image

Instead of TweenService why don’t you use TweenPosition?

It’s because you’re using curly brackets. It’s thinking the table you’re giving is the first argument.

I already solved that. Its a different issue now