I cant tween transparency

Hi Im Using a piece of code and trying to tween transparency of a part, when I run the code it waites for a second then sets transparency to 1 instead of tweening it I can tween things like cframes etc. but it rejects tweening transparency, why?

game:GetService("TweenService"):Create(Hit,TweenInfo.new(1),{Transparency = 1}):Play()
1 Like

Can I see the rest of the code?
also, Idk if it would stop it from working but its better practice to do something like

local tween = game:GetService("TweenService"):Create(Hit,TweenInfo.new(1),{Transparency = 1})
tween:Play()

that way you have tween.Completed and :Stop()

1 Like

Im sure it has no difference but I still tried it, and it didnā€™t work as expected

maybe adding easingstyle/easingdirection should fix it?
easing styles: styles
easing directions: directions

local tween = game:GetService("TweenService"):Create(Hit, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Transparency = 1})
tween:Play()

Iā€™m taking a complete guess here, so idk.
I tried the script on itā€™s own in a blank studio, defining ā€˜Hitā€™ as a part in the workspace. So in my case, the tween is set to run instantly as soon as the game starts. If that is the same in your case, then I managed to make the tween show up by either 1) changing TweenInfo.new(1) to a higher value, like 5 or 2) adding wait(1) before the tween.

If thatā€™s not the case, then perhaps something else in the script is causing the tween to not run correctly?

May be a dumb question, but since 1 second is really low, you may be trying to run the game and when rendered, the tween has already ended

nothing changed as expected, I have no idea why its not working :frowning:

Pretty sure it has nothing to do with that since it has a wait before but still I did tried that before and no difference it just waits X amount of time and sets transparency to 1 like it does rn

Update: I did a small test and it turns out it does work with other parts but its not working for the part ā€œHitā€ I donā€™t know why since it literally has the same properties

Iā€™m not even sure what the ā€œHitā€ is supposed to be.

Just A part In workspace, nothing special

Problem would be that youā€™re not referencing the part inside the script, Keep in mind that itā€™s best to Create variables for it first and never add it directly without creating it (you mightā€™ve heard with "Unknown Global ā€˜Hitā€™ ")

local Hit = script.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(1, Enum.EasingDirection.Out, Enum.EasingStyle.Linear) --You don't need 2 of enums, keep it or remove it as you want

local TweenSet = TweenService:Create(Hit, tweenInfo, {Transparency = 1})
TweenSet:Play()

I did referanced it, its not the full script

Have you tested on both client and server? Maybe thereā€™s a replication issue / it is client sided

Also this has nothing to do, but although Lua accepts defining names in dictionaries like variables, you shouldnt do that, instead, for your muscle memory, use [""], because the other way around the script can confuse it with other variables etc

Hi, after doing a lot of testing, you need to use the easingstyle quart and easingdirection out. (sorry, I know its been a long time)