My Frame Gui Is Not Tweening Its BackgroundTransparency

I have a screen gui, a frame, that obscured the player’s vision until it is removed. I want to tween it to transparency, and that seems easy, as I thought it would be, but actually a problem occured. here is the code:

local core = coroutine.create(function()
	
	repeat wait(1.5)
		
		script:WaitForChild('Metal Step'):Play()
		
	until stop
	
	wait(1.5)
	
	script:WaitForChild('Concrete Step'):Play()
	
	wait(2)
	
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
	local propTable = {BackgroundTransparency = 1}
	local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'), tweenInfo, propTable)
	tween:Play()
	
	tween.Completed:Wait()
	
	introduction.Enabled = false
	
	camera.CameraType = Enum.CameraType.Custom
	human.WalkSpeed = 11
	
end)
coroutine.resume(core)

as you can see near the end i try to tween the frame to transparency, however it does not work. The frame simply remains opaque until the tween is done and then it suddenly disappears. I have no idea why this is happening, but can someone please let me know how to stop this?

1 Like

My guess is that you did not take the correct path to the frame. My hypothesis; I made a simple remake of your code and setup (altering it slightly to have it work for me, because I do not know what you put as stop or introduction) and made it into this;

image
The workspace.

local introductionFrame = script.Parent.IntroductionFrame

local steps = 0

local core = coroutine.create(function()
	
	repeat wait(0.5)
		
		script["Metal Step"]:Play()
--//You can use 'Instance[string]' to search for a child of the instance with a multiple word name.
		steps+= 1
		
	until steps == 5
	
	wait(0.5)
	
	script["Concrete Step"]:Play()
	
	wait(2)
	
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
	local propTable = {BackgroundTransparency = 1}
	local tween = game:GetService('TweenService'):Create(introductionFrame, tweenInfo, propTable)
	tween:Play()
--//Note that I did not change anything about the TweenInfo or propTable other than the instance.
	
	tween.Completed:Wait()
	
	introductionFrame.Visible = false
	
	print("Completed.")
	
end)

coroutine.resume(core)

And it worked fine for me, the frame in my screen slowly faded away after the footsteps played.


So, double check if your introduction path is correct.

2 Likes

image_2024-02-29_195140449
thats my setup, and the variable introduction = playerGui:WaitForChild(‘Introduction’)

in addition, there is no error message when the script runs.

1 Like
  • Is your path to the PlayerGui folder correct?
  • What for script is it and where is it located in the explorer?

Those are just two things you can ask yourself, but the fault is definitely not in the Tween, because I copied it letter for letter and it works.

Add debugging 'print()'s to your code and print out all your variables after you make them. If it’s an instance, click the Output message and see if it prints the right instance.

2 Likes

the script is stored under playerscripts, and yes, the playergui path is right

1 Like

would you like the full code sample? it might help you understand the problem? (153 lines)

1 Like

I was going to say. I copied the entire structure and code without changing anything and it worked for me, so the issue must be somewhere else in the script.

Explorer + Code

image

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local playerGui = player:WaitForChild("PlayerGui")
local introduction = playerGui:WaitForChild("Introduction")

local steps = 0

local core = coroutine.create(function()
	
	repeat wait(0.5)
		
		script["Metal Step"]:Play()
		steps+= 1
		
	until steps == 5
	
	wait(0.5)
	
	script["Concrete Step"]:Play()
	
	wait(2)
	
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
	local propTable = {BackgroundTransparency = 1}
	local tween = game:GetService('TweenService'):Create(introduction:WaitForChild("Frame"), tweenInfo, propTable)
	tween:Play()
	
	tween.Completed:Wait()
	
	introduction.Enabled = false
	
	print("Completed.")
	
end)

coroutine.resume(core)
1 Like

i just want to say i appreciate the help so far!
ok here you go:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local human = character:WaitForChild('Humanoid')
local root = character:WaitForChild('HumanoidRootPart')
local camera = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local id = player.UserId

local playerGui = player.PlayerGui

local introduction = playerGui:WaitForChild('Introduction')
introduction.Enabled = true

local cameraGui = playerGui:WaitForChild('Camera Effects')
cameraGui.Enabled = false

if not game:GetService('UserInputService').KeyboardEnabled and not game:GetService('UserInputService').GamepadEnabled then
	
	playerGui:WaitForChild('MOBILE').Enabled = true
	
end

human:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
human:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
human:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)

game:GetService('UserInputService').MouseIconEnabled = false

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

for i, v in pairs(character:GetChildren()) do
	
	if v:IsA('BasePart') and v.Name ~= 'Head' then
		
		v:GetPropertyChangedSignal('LocalTransparencyModifier'):Connect(function()
			
			v.LocalTransparencyModifier = 0
			
		end)
		
	end
	
end

repeat wait()
	
	local success, failure = pcall(function()
		
		game.StarterGui:SetCore('ResetButtonCallback', false)
		
	end)
	
until success

script:WaitForChild('Ambience'):Play()

player.CameraMinZoomDistance = 0.5
player.CameraMaxZoomDistance = 0.5
human.CameraOffset = Vector3.new(0, 0, -1)
cameraGui.Enabled = true
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = character:WaitForChild('Head').CFrame + Vector3.new(0, 0, 1)
camera.CFrame = CFrame.Angles(0, math.rad(180), 0)

local stop = false

local core = coroutine.create(function()
	
	repeat wait(1.5)
		
		script:WaitForChild('Metal Step'):Play()
		
	until stop
	
	wait(1.5)
	
	script:WaitForChild('Concrete Step'):Play()
	
	wait(2)
	
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
	local propTable = {BackgroundTransparency = 1}
	local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'), tweenInfo, propTable)
	tween:Play()
	
	tween.Completed:Wait()
	
	introduction.Enabled = false
	
	camera.CameraType = Enum.CameraType.Custom
	human.WalkSpeed = 11
	
end)
coroutine.resume(core)

wait(3)

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {ImageTransparency = 0}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('RGB Studios'), tweenInfo, propTable)
tween:Play()

tween.Completed:Wait()

wait(1)

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {TextTransparency = 0}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('TextLabel'), tweenInfo, propTable)
tween:Play()

tween.Completed:Wait()

wait(2.5)

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {ImageTransparency = 1}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('RGB Studios'), tweenInfo, propTable)
tween:Play()
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {TextTransparency = 1}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('TextLabel'), tweenInfo, propTable)
tween:Play()

tween.Completed:Wait()

wait(2.5)

script:WaitForChild('Tense Sound'):Play()

introduction:WaitForChild('Frame'):WaitForChild('Title').TextTransparency = 0
introduction:WaitForChild('Frame'):WaitForChild('Version').TextTransparency = 0

wait(5.5)

local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {TextTransparency = 1}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('Title'), tweenInfo, propTable)
tween:Play()
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local propTable = {TextTransparency = 1}
local tween = game:GetService('TweenService'):Create(introduction:WaitForChild('Frame'):WaitForChild('Version'), tweenInfo, propTable)
tween:Play()

tween.Completed:Wait()

wait(1.5)

stop = true
1 Like

In lines 69 to 77, you never change the ‘stop’ BoolValue to true, not until line 153, the last line.
Since I am not able to run the script, I can not be a 100% certain, but I am guessing this will cause in the repeat .. until loop repeating until all of the other tweens have finished. That’s when the screen suddenly turns back.

1 Like

this code essentially covers the screen and then plays some tweens, before then letting the player see again at the end of the script, so yes all other tweens play first.

1 Like

So far I am guessing that all the tweens play correctly, but then the BackgroundTransparency of the ScreenGui does not change, but it does disappear after two seconds, meaning the

tween.Completed:Wait()

has been triggered.

Could it be that other frames also have backgrounds on? That the tween does play and the Frame’s transparency fades, only under is still opaque until the .Enabled is set to false.

EDIT: Mind was not in the right place, I meant Frame instead of ScreenGui.

what do you mean? I dont know of a ‘background’ property in the screenGui

1 Like

i think i may know what is happening

1 Like


at the bottom of this image you can see stars? does that mean the gui is not enabled?

1 Like

ive found the issue, and i feel like an idiot. the frame was meant to start on a transparency of zero, but it was on one. im sorry to waste your time lemna. i really appreciate the help!

2 Likes

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