Problem with TweenService

Idk what’s up but my script is not working. Its just a basic TweenService script that gets triggered by a text button (button.MouseButton1Click:Connect(newgui))

script

local button = script.Parent
local screen2 = script.Parent.Parent.Screen2
local screenframe = script.Parent.Parent.Parent.ScreenGui2.Frame
function newgui()
	
	screenframe.Visible = true
	
	local tweenService = game:GetService("TweenService")
	local tweenInfo = TweenInfo.new(
		1, -- length of tween
		Enum.EasingStyle.Quint, -- easing style of tween
		Enum.EasingDirection.Out, -- direction of easing
		0, -- number of times to repeat (leave at 0 for infinite)
		false, -- reverses the tween if true
        0.0) -- delay before starting the tween
end

video


Reply if u can help. Specifically the “Begin Button,” triggers the Tween. The Begin should open a new Gui which contains a frame, and fades in.

3 Likes

There doesn’t appear to be any part in the script which actually plays a tween.

local button = script.Parent
local screen2 = script.Parent.Parent.Screen2
local screenframe = script.Parent.Parent.Parent.ScreenGui2.Frame
function newgui()
	screenframe.Visible = true
	
	local tweenService = game:GetService("TweenService")
	local tweenInfo = TweenInfo.new(
		1, -- length of tween
		Enum.EasingStyle.Quint, -- easing style of tween
		Enum.EasingDirection.Out, -- direction of easing
		0, -- number of times to repeat (leave at 0 for infinite)
		false, -- reverses the tween if true
        0.0) -- delay before starting the tween

    local newTween = tweenService:Create(screenframe, tweenInfo, {Position = UDim2.new(0.5, 0, 0.5, 0)})
    -- i don't know how exactly you want the tween to work, you have to fill in your own info
    newTween:Play()
end

I would also suggest using button.Activated:Connect(newgui) instead of MouseButton1Click, to support devices which don’t have a mouse.

2 Likes

MouseButton1Click can work on almost devices, like mobile.

2 Likes

Still doesn’t work…
Btw the game is only a test for my new scripter brain

What is the position and anchor point of the local screenframe = script.Parent.Parent.Parent.ScreenGui2.Frame

1 Like

Its not Visible, But when you make it visible, it fills the screen.
(exactly, position {-0.026, 0},{-0.137, 0}. anchor point 0,0

Make the anchor point to .5, .5
and the position .5, 0, .5, 0

What are you about to tween though?

Makes the Frame fade in

local tweenService = game:GetService("TweenService")
	local tweenInfo = TweenInfo.new(
		1, -- length of tween
		Enum.EasingStyle.Quint, -- easing style of tween
		Enum.EasingDirection.Out, -- direction of easing
		0, -- number of times to repeat (leave at 0 for infinite)
		false, -- reverses the tween if true
		0.0) -- delay before starting the tween

after button clicked

Okay! I get it! Last request can you take a screenshot of the property of the screenframe? Please include as much as possible.

Apologies for my late reply,

Also, a red message in my output lists:
" 15:32:45.411 Workspace.Script:2: attempt to index nil with 'newframe1' - Server - Script:2

A server script? That’s an interesting choice for UI.
Can we see your full code?
Also, your script is in workspace. I do not recommend placing scripts in workspace for security reasons.
What you should do instead is have a LocalScript instead underneath your GUI. This way, you can easily reference everything.

Here is the script for the Button
(Which is supposed to cause a frame to fade in from a new Gui)

local button = script.Parent
local screen2 = script.Parent.Parent.Screen2
local screenframe = script.Parent.Parent.Parent.ScreenGui2.Frame
function newgui()
	screenframe.Visible = true

	local tweenService = game:GetService("TweenService")
	local tweenInfo = TweenInfo.new(
		1, -- length of tween
		Enum.EasingStyle.Quint, -- easing style of tween
		Enum.EasingDirection.Out, -- direction of easing
		0, -- number of times to repeat (leave at 0 for infinite)
		false, -- reverses the tween if true
		0.0) -- delay before starting the tween

	local newTween = tweenService:Create(screenframe, tweenInfo, {Position = UDim2.new(0.5, 0, 0.5, 0)})
	
	newTween:Play()
end

Here is code for the tweeting the Textlabel, Button, and the “Whats new” Gui’s

local text1 = script.Parent
local screengui = script.Parent.Parent
local new = script.Parent.Parent.WN

screengui.IgnoreGuiInset = true

function tween1()
	
	print("function tween1 running...")
	
	local TweenService = game:GetService("TweenService")
	
	local tweenInfo = TweenInfo.new(
		0.8, -- duration
		Enum.EasingStyle.Cubic, -- easing style
		Enum.EasingDirection.Out, -- easing direction
		0, -- repeat count (use -1 for infinite)
		false, -- reverses the tween if true
        0.5) -- delay in seconds before starting the tween
	
	local goal = {}
	goal.Position = UDim2.new(0.5,0,0.5,0)
	
	local tween = TweenService:Create(text1,tweenInfo,goal)
	tween:Play()
end


wait(2)
tween1()

local startbutton = script.Parent.Parent.Begin

function tween2()
	
	--make tween service and make it allign next to the center of text1
	local TweenService = game:GetService("TweenService")
	
	local tweenInfo = TweenInfo.new(
		0.8, -- duration
		Enum.EasingStyle.Elastic, -- easing style
		Enum.EasingDirection.Out, -- easing direction
		0, -- repeat count (use -1 for infinite)
        false, -- reverses the tween if true
        0.5) -- delay in seconds before starting the tween
	
	local goal = {}
	--make the finish position in the exact center of the screen
	goal.Position = UDim2.new(0.2,0,0.6,0)
	
	local tween = TweenService:Create(startbutton,tweenInfo,goal)
	tween:Play()
end
	

	wait(1.55)
tween2()

wait(2.2)
new.TextTransparency = 0
new.TextStrokeTransparency = 0

Thanks

Your code’s a little messy, but I can immediately spot one thing: you never call the newgui function in the first script.
Also, where is newframe1? None of your scripts reference it but you’re getting an error for it.

Im workin on it, Its my 4th day scripting ever… but I feel like im staring to get some of it

I used button.MouseButton1Click:Connect(newgui) to run the function. However, nothing appears to happen. Im confused with “Newframe1” as well. but ill try to find the problem.

Ill change to local script as well

Just wondering if anyone is still on this topic, im still having trouble.
:cool:

Where? Are you sure this is the full script? We can’t really help if you’re omitting parts…

Yes, it’s the full script, i just can’t get it to work.
I will edit the post soon to include everything i mentioned

I can’t see where you used button.MouseButton1Click:Connect(newgui)