Script isn't making text fade in and out

  1. Tweening the textransparency of an object and making it appear for a few seconds (Fade-in/Fade-out) effect being made using tweens.

  2. Okay so I may have an idea of the issue, but it doesn’t make any sense to me. The script is unsuccessful in changing the text label’s text transparency property but it tweening is going through which means it is working.

It’s either the referencing (which isn’t likely) or the actual tweening not functioning as intended. No in-game errors and all print statements go through. I almost forgot to mention, but the part on touch is working perfectly fine (the sound is being played and prints go through)

The screengui is set to enabled by default and the textfont is set to visible / texttransparency set to 1 by default. No other ui is in the way of it appearing.

  1. I’ve tested changing the transparency using a separate script and that worked successfully, so it isn’t an issue with the actual textlabel or screengui.
local Players = game:GetService("Players")
local soundService = game:GetService("SoundService")
local tweenService = game:GetService("TweenService")
local startergui = game:GetService("StarterGui")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

script.Parent.Enabled = true

local function createTitle(partName, soundName, titleName, partSize, partPosition)
	local part = Instance.new("Part")
	part.Name = partName
	part.Size = partSize
	part.CFrame = CFrame.new(partPosition)
	part.CanCollide = false
	part.Anchored = true
	part.Transparency = 1
	part.CastShadow = false
	part.Parent = workspace.Barriers
	mouse.TargetFilter = part

	local titleSound = soundService.AreaTitleSounds[soundName]
	local title = startergui.AreaTitleScreen[titleName]

	local lastTriggered = 0 -- Moved inside the createTitle function

	local function playTitleAndSound()
		local currentTime = os.time()
		if currentTime - lastTriggered < 60 then
			return
		end
		lastTriggered = currentTime

		titleSound:Play()

		local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
		local properties = {TextTransparency = 0}
		local showTitleTween = tweenService:Create(title, tweenInfo, properties)
		showTitleTween:Play()

		wait(3)

		local fadeProperties = {TextTransparency = 1}
		local fadeTween = tweenService:Create(title, tweenInfo, fadeProperties)
		fadeTween:Play()
	end

	part.Touched:Connect(playTitleAndSound)
end

-- In-game Titles (Remember: Make each text transparency set to "1" so it automatically appears through the fade-in)
createTitle("FrostwoodTrigger1", "AreaTitleSound1", "Frostwood", Vector3.new(20, 27, 1), Vector3.new(0, 14.5, 49.75))

Sorry for rushing through this question, I’m a little desperate for someone to point any errors out or methods in trying to find the issue. Any/All feedback is appreciated.
Startergui picture

Hey! I know what it the issue here, the problem is that you’re changing the UI in StarterGui, and not from the player’s screen (game.Players.LocalPlayer.PlayerGui)

Here’s a quick fix! (there’s not much to change, just a silly mistake!)

local Players = game:GetService("Players")
local soundService = game:GetService("SoundService")
local tweenService = game:GetService("TweenService")
local startergui = game:GetService("StarterGui")
local player = Players.LocalPlayer
local titleUI = script.Parent --You can also set it to player.PlayerGui:FindFirstChild("Name")
local mouse = player:GetMouse()

script.Parent.Enabled = true

local function createTitle(partName, soundName, titleName, partSize, partPosition)
	local part = Instance.new("Part")
	part.Name = partName
	part.Size = partSize
	part.CFrame = CFrame.new(partPosition)
	part.CanCollide = false
	part.Anchored = true
	part.Transparency = 1
	part.CastShadow = false
	part.Parent = workspace
	mouse.TargetFilter = part

	local title = titleUI[titleName]

	local lastTriggered = 0 -- Moved inside the createTitle function

	local function playTitleAndSound()
		local currentTime = os.time()
		if currentTime - lastTriggered < 60 then
			return
		end
		lastTriggered = currentTime

		local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
		local properties = {TextTransparency = 0}
		local showTitleTween = tweenService:Create(title, tweenInfo, properties)
		showTitleTween:Play()

		wait(3)

		local fadeProperties = {TextTransparency = 1}
		local fadeTween = tweenService:Create(title, tweenInfo, fadeProperties)
		fadeTween:Play()
	end

	part.Touched:Connect(playTitleAndSound)
end

-- In-game Titles (Remember: Make each text transparency set to "1" so it automatically appears through the fade-in)
createTitle("FrostwoodTrigger1", "AreaTitleSound1", "Frostwood", Vector3.new(20, 27, 1), Vector3.new(0, 14.5, 49.75))
2 Likes

Thank you so much! I’ve been searching for hours now and I thought it was an issue with the tweening or referencing. Massive relief and thank you again, I mean it. Wishing you the best, SkyleTheFrench!

2 Likes

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