Gui not changing trans

Hello, so as the title explains, the transparency won’t change when a button is clicked.
Code:

  local ts = game:GetService("TweenService")
local unit = game.StarterGui.IfYesHit.Guide
local goal = {}
goal.Transparency = 0
local tw = ts:Create(unit,TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0),goal)
game.StarterGui.IfYesHit.Enabled = true
function hi ()
	tw:Play()
	script.Parent.Parent.Enabled = false
end
script.Parent.MouseButton1Click:Connect(hi)

There are no errors in output.
I’m very sorry if there is alot of missing information, just tell me if there is. Thank You.

2 Likes

I’m not really familiar with that type of scripting yet, but I personally do this:

repeat
    wait(0.5)
    script.Parent.BackgroundTransparency += 0.1
until script.Parent.BackgroundTransparency == 1

Hope it can solve your problem. Have a good day! :happy3:

I could have done that, but tween service has EasingStyle. Just check the EasingStyle page on the DevHub and you will know what I mean.

Do this

tw:Play()
tw.Completed:Wait()

Will fix everything.

Your function should look like this at the end

function hi ()
	tw:Play()
	tw.Completed:Wait() 
	script.Parent.Parent.Enabled = false
end

Has fixed half of the problem. When I click the button, the screengui that the button is in dissapears, but no IfYesClicked gui pops out.

It isn’t a part of your function.

I added the IfYesClicked but still does not work. In fact i’m just going to use a for count to do this. OR use Nicx0ffline’s code.

function hi  ()
	for count = 0,1,-0.1 do
		--whatever
	end
end
1 Like

It isn’t Smooth at all, your choice tho.

If you want you can still try this

local ts = game:GetService("TweenService")
local unit = game.StarterGui.IfYesHit.Guide
local goal = {}
goal.Transparency = 0
local tw = ts:Create(unit,TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0),goal)
game.StarterGui.IfYesHit.Enabled = true
function hi ()
	tw:Play()
	tw.Completed:Wait() 
	script.Parent.Parent.Enabled = false
	game.StarterGui.IfYesHit.Enabled = true
end
script.Parent.MouseButton1Click:Connect(hi)