How to make a part fade out?

Hello everyone sorry for bothering, but how could I make a part fade smoothly with the TweenService?

Here the script I tried

local TweenService = game:GetService("TweenService")

local part = script.Parent

local partTween = TweenService:Create(part, TweenInfo.new(), {Transparency = 1})

part.Touched:Connect(function(otherPart)
	local humanoid = otherPart.Parent:FindFirstChildWichIsA("Humanoid")
	if humanoid then
		partTween:Play()
	end
end)
1 Like

To make it fade away you would have to make its transparency go to 1.

3 Likes

Tween info cannot be empty! Look here TweenInfo | Roblox Creator Documentation
This should work after your add arguments to tween info. If u have any questions then feel free to ask.

1 Like

My bad! I typed it wrong ! But thanks you for the help ! :grin:

I’m pretty new to scripting so thanks for the help! I’ll look into it !

1 Like

The main issue is that you are setting the transparency to 0, 0 being visible, not transparent.
Instead set it to 1 and for TweenInfo | Roblox Creator Documentation this can be left open as there are default values for each property of TweenInfo, though I suggest to only add a property time to it.

TweenInfo.new(1) -- first property is time.

Note, @blokav, already stated this fix.

If this answers your question please mark a post as solution.

So the script should be:

local TweenService = game:GetService("TweenService")

local part = script.Parent

local partTween = TweenService:Create(part, TweenInfo.new(), {Transparency = 1})

part.Touched:Connect(function(otherPart)
	local humanoid = otherPart.Parent:FindFirstChildWichIsA("Humanoid")
	if humanoid then
		partTween:Play()
	end
end)
2 Likes

Tween info is how long the tween will take, times it repeats, weather or not it reverses, and the easing style and easing dierection. Its what makes the tween the tween

1 Like

The reason why it isn’t working is because tween info is empty. You kept it empty.

1 Like

Ahh thanks! Now I understand !

Do you mind putting the post I put as solution? So if someone has the same issue they can look at it

1 Like

This is incorrect, there are already default properties for TweenInfo, if you have every tried Tween before it is caused by that. Please read the next reference Oops!


As it shows here the time is set to 1 as default, this can be changed but is not required to change.

Note that if you were correct the script would most-likely error which it did not, nor would do.
Please test your theory for yourself.

@Srnqe, please mark my previous post as solution.

1 Like

For some reasons it still doesn’t work ? :sweat_smile:

Did you keep tween info as empty?

No ? I put 1,0 (I apologize for the inconvenient ! :sweat_smile: )

U need ALL arguments.


Tweeninfo.new(Time:number, easingstyle:enum.easingstyle, easingdirection:enum.easingdierection,reapeatcount:number,reverses:bool(true or false,delaytime:number) 

edit each of these to be ur desired argument.

This still wouldn’t work as “FindFirstChildWichIsA” should be “FindFirstChildWhichIsA”.

2 Likes
local TS = game:GetService("TweenService")
local part = script.Parent
part.Transparency = 0
local partTween = TS:Create(part, TweenInfo.new(3), {Transparency = 1})

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		partTween:Play()
	end
end)

Here’s your working script, although 3 seconds may be too slow, so feel free to change the tween length.

3 Likes

My bad sorry! I didn’t understand it like that ! :sweat_smile:

You don’t actually need all arguments, in fact you don’t need any, but if you want the tween to actually look like an animation and not an instant transition then you’ll at least need the first argument (the duration of the tween).

1 Like

Thanks you! Now I see my errors :sweat_smile: