Textlabel not tweening for unknown reason

Hey all! I’ve been using tweens in my game for a while now, but for some reason I am unable to make a screenGUI tween upon clicking a block despite using the same code in a loading screen that also tweens GUIs.

Upon clicking the block, the tween does not play and there are no visual indicators of what I am trying to tween. The clickdetector still works, as clicking the block makes the GUI show up, but for some reason, the tween is not played upon click.

I’ve tried looking at my loadingscreen script that I created with very similar code, and tried copy and pasting that into my new script. It still refuses to work, and I’m unsure why.

This is the small amount of code I currently have. Is there anything wrong? I get no errors upon click.
Thanks!

local Menu2 = game.StarterGui.Menu2
local Frame = game.StarterGui.Menu2.Frame1
local TextThing = game.StarterGui.Menu2.Frame1.TextThing
local TweenService = game:GetService("TweenService")

script.Parent.Enabled = false
game.Workspace.ClickBlock.ClickDetector.MouseClick:connect(function()--Click prompt triggered
	script.Parent.Enabled = true
	
	local Info = TweenInfo.new(2.5) --Goodbye text!
	local Tween = game:GetService("TweenService"):Create(TextThing,Info,{TextTransparency=0})
	Tween:Play()

	local Info = TweenInfo.new(2.5) --Goodbye background!
	local Tween3 = game:GetService("TweenService"):Create(TextThing,Info,{BackgroundTransparency=0})
	Tween3:Play()
	
end)

I don’t know if this has to do anything with the script but I’m pretty sure you have to reference the GUI in the PlayerGui and not StarterGui

I sort of understand what you mean, how would I reference that? I usually use StarterGui in my GUI scripts, and I’ve never had any issues with that before until now

Ok so I think the problem is that you didn’t set the transparencies of the objects to 1. All you did was disable the ScreenGui so when you enable it the objects just become visible. Try changing the transparencies to 1 before.

Also can you clarify what kind of effect you’re going for?

local TweenService = game:GetService("TweenService")

local LocalPlayer = game.Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local Menu2 = PlayerGui:WaitForChild("Menu2")
local Info = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) -- You can check the API Reference if this effect isn't what you're looking for.

local Frame = Menu2.Frame1
local TextThing = Frame.TextThing

script.Parent.Enabled = false
game.Workspace.ClickBlock.ClickDetector.MouseClick:connect(function()--Click prompt triggered
	script.Parent.Enabled = true
	

	local Tween = TweenService:Create(TextThing,Info,{TextTransparency=0})
	Tween:Play()

	local Tween3 = TweenService:Create(TextThing,Info,{BackgroundTransparency=0})
	Tween3:Play()
	
end)

Try this, All I did was reference the PlayerGUI. Not sure why you created a variable for Frame1 and then only used it for declaring another variable. Might be that you’re not using Frame1 in the Tween, which might be why what you’re trying to do isn’t happening.

Edit: Added The rest of the TweenInfo, thank you @SloppyBanana225 for noticing that.

1 Like

You need the EasingStyle and EasingDirection in the TweenInfo.

1 Like

Have done this beforehand and it didn’t seem to make any changes. The effect I’m going for is to make the GUI disappear upon clicking an ingame block. My plan is to make it appear in reality, but I’m just making it disappear for now to test the tweening which doesnt seem to work

If it’s in a script that won’t work.

He might be using it in the same script but for a different use.

Welll… you made it so when the object is clicked it turns the UI’s transparency into 0 so I’d change that to 1

And also you don’t need to tween to change the transparency of an object

Ahh, yeah it was the TweenInfo, I completely forgot about that. For some reason in my other script, I forgot that as well and it seems to work just fine? I’ll rewrite it later with this new information, but for now thank you for writing this out! And thank you SloppyBanana225 for the tweeninfo information!

Ingame I was just testing out whether I could make it visible or invisible by tweening, so they are interchangeable for me atm, just was unsure why tween wasnt working. I know I can simply make the GUI visible or invisible in different ways but prefer tweening as I want the GUI to fade in instead of appear suddenly.

Here is a simple fade script if you need it

local f = (insert object location here)

for i = f.BackgroundTransparency, 0, 0.1 do -- keep it on 0 if you want it 
--fade in and change if to 1 for fade out
	entire.BackgroundTransparency = i
	wait(0.1)
end

If you want the UI to just fade then you shouldn’t be using things like EasingStyle and Easing Direction