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)
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.
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.
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)
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
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!
Tweeninfo.new(Time:number, easingstyle:enum.easingstyle, easingdirection:enum.easingdierection,reapeatcount:number,reverses:bool(true or false,delaytime:number)
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.
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).