Tween doesnt work

basically, i have a tween that should change transparency of a TextLabel. however, the tween doesnt show, although it does play. this is what it looks like:

some of the code:

local W = PlayerGui:WaitForChild("W")

local tweenInfo = TweenInfo.new(
	1, -- Time
	Enum.EasingStyle.Quad, -- 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
)

local Wtween = TweenService:Create(W.TextLabel, tweenInfo, {Transparency = 1})
Wtween.Completed:Connect(function()
	W.TextLabel.Transparency = 0
end)



function chooseKey()
	local ChosenKey = math.random(1,5)
	if ChosenKey == 1 then
		W.Enabled = true
		print("W")
		wKey = true
		aKey = false
		sKey = false
		dKey = false
		spaceKey = false
end
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W and wKey then
		W.Enabled = false
		KeyPressed = true
		Wtween:Play()
		task.wait(.5)
		chooseKey()
		

	end
end)





chooseKey()
1 Like

Put your key stuff before the tween, it would make sense since the script will need to figure out what youā€™re doing, and then what is going to happen after that.

doesnt do anything, and the tween is already fine before then

any errors inside of the output?

no, i also dont think the tween is incorrect

Try moving the ā€˜UIS.InputBeganā€™ block outside the chooseKey function. You only want to connect to that once. Also, set wkey = false right after
ā€˜if input.KeyCode == Enum.KeyCode.W and wKey thenā€™
That will act as a debounce so the tween only plays once.

the script i posted wasnt to full script, it was the main parts; the uis wasnt in the choosekey function.
this is what i did:

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W and wKey then
		wKey = false
		W.Enabled = false
		KeyPressed = true
		Wtween:Play()
		task.wait(.5)
		chooseKey()
		

	end
end)

still doesnt work though, no errors

This property is deprecated
https://developer.roblox.com/en-us/api-reference/property/GuiObject/Transparency

1 Like

good to know, but nothing changed

May I ask? What have you changed?

.

didnt change anything? same error

Are you sure you are playing the tween?

its played, but i changed ā€œTransparencyā€ to BackgroundTransparency

My bad I tested it with just the transparency property and it seemed to work.
https://gyazo.com/1044488bcc30b3e398a1b0709676a15c.gif

Code written
	local T_Info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
	TweenService:Create(script.Parent,T_Info,{Transparency = 1}):Play()
	wait(1)
	TweenService:Create(script.Parent,T_Info,{Transparency = 0}):Play()

well if i did my tween code with a simple gui of course it would work, my code isnt 1 ui

local W = PlayerGui:WaitForChild("W")
Would W be a screenGui?

1 Like

yeah, here are some of the locals:

local PlayerGui = game.Players.LocalPlayer.PlayerGui
local W = PlayerGui:WaitForChild("W")

how did i not notice thisā€¦

the problem was that i was disabling the UI before tween played.

bru