How would I tween transparency?

Hey, so I am aware there are quite a few topics on this, but I can’t seem to get my finger properly around it.

-- \\ VARIABLES \\
local Player = game:GetService("Players").LocalPlayer
local PlayerGUI = Player.PlayerGui
local AMann = PlayerGUI:WaitForChild("AMAnnouncement")
local AMFrame = AMann:WaitForChild("AMFrame")
local RemoteEvent = game.ReplicatedStorage.AMEvent
local AMLabel = AMFrame.AMLabel

-- \\ CATCHES WHEN ADONIS IS FIRED \\
RemoteEvent.OnClientEvent:Connect(function(message)

	local Label2 = AMFrame.AMLabel.AMLabel2
	Label2.Text = message

	local TS = game:GetService("TweenService")

-- \\ TWEEN CONFIGURATION \\
	
	local tInfo = TweenInfo.new(
		5, -- Time/Speed
		Enum.EasingStyle.Quint, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	-- \\ CREATES TWEENS \\
	local FadeIn = TS:Create(AMLabel, tInfo, {ImageTransparency = 0})
	local FadeOut = TS:Create(AMLabel, tInfo, {ImageTransparency = 1})

FadeIn:Play()
local Label2 = AMFrame.AMLabel.AMLabel2
Label2.Text = message
Label2.Visible = true
wait(3)
Label2.Visible = false
FadeOut:Play()
end)

This is my script I have so far, to fade and fade out a Tween, I really have no clue what’s going wrong as I’ve used this script twice, the first one worked, the second didn’t.

Please do explain your response so I can fully capture what you mean

2 Likes

Elaborate a little on that, as if your using 2 scripts that may be clashing with each other.

Alright, allow me to send both scripts, the scripts are quite messy with variable names, that’s my focus after this, that’s the first use of the script, this is the second use:

-- \\ VARIABLES \\
local Player = game:GetService("Players").LocalPlayer
local PlayerGUI = Player.PlayerGui
local AMann = PlayerGUI:WaitForChild("QAAnnouncement")
local AMFrame = AMann:WaitForChild("QAFrame")
local RemoteEvent = game.ReplicatedStorage.QAEvent
local AMLabel = AMFrame.QALabel

-- \\ CATCHES WHEN ADONIS IS FIRED \\
RemoteEvent.OnClientEvent:Connect(function(message)

	local Label2 = AMFrame.QALabel.QALabel2
	Label2.Text = message

	local TS = game:GetService("TweenService")

	-- \\ TWEEN CONFIGURATION \\

	local tInfo = TweenInfo.new(
		5, -- Time/Speed
		Enum.EasingStyle.Quint, -- EasingStyle
		Enum.EasingDirection.Out, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	-- \\ CREATES TWEENS \\
	local InFade = TS:Create(AMLabel, tInfo, {ImageTransparency = 0})
	local OutFade = TS:Create(AMLabel, tInfo, {ImageTransparency = 1})

	InFade:Play()
	Label2.Visible = true
	wait(3)
	OutFade:Play()
	Label2.Visible = false
end)

You probably connect the function in 2 different scripts, and they are probably clashing with each other.

Do you get any errors in console, and elaborate on how it doesn’t work, does it not fade in, or is the animation not working?

These are 2 different scripts.

The main issue is when FireAllClients is used, both the scripts fail to properly fade in.

No issues within the console.

I would try making a for loop for all the players in the server and just use :FireClient() and pass the player from the for loop. I tried simplifying your code in studio and im also having trouble getting it to work.

This script is meant to go towards all Clients, I’ve been told that for loops are way less efficient.

I will for sure check out for loops though, thank you for your assistance.

I would also try adding a small delay for all the elements to load, including the label and the remote event, mixed with a small task.wait() could work, worked for me at least.

Here’s the code if your interested:

Server:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lol = ReplicatedStorage:WaitForChild("RemoteEvent")

task.wait(1)

Lol:FireAllClients("Hello")

Local:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lol = ReplicatedStorage:WaitForChild("RemoteEvent")

Lol.OnClientEvent:Connect(function(msg)
	print(msg)
end)

Okay so,

I did a little bit of digging and discovered something quite odd, when I put the AMFrame & AMLabel to Visible before joining Studio Testing, it worked fine.

But when I tried hiding the UIs and joining studio testing, it didn’t seem to work.

I think you just forget to turn the visibility back on when joining lol. Just make them visible but set the transparency to 1. Or set the visibility back to true at the last second.

OMG!

you’re completely right, the minute I read over your message I slowly figured out how dumb I was and missed that.

Thanks a bunch, haha.

Its fine, happens to me, anyway hope that fixes it lol.

3 Likes

Works like a charm, thank you so much mate.

1 Like

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