Hello! I can help you with this.
I will give a step by step guide as to not just give it away, instead help you learn.
The first thing we want to do is make a variable for the service. It will look something like this.
local tweenservice = game:GetService("TweenService")
Once we have done that, we want to make a few extra variables that hold information that we will use in the tween.
local tweenservice = game:GetService("TweenService")
local UI = script.Parent
local info = TweenInfo.new(
3, -- Time it takes to fade
Enum.EasingStyle.Linear -- Type of transition
)
local startpoint = {}
startpoint.BackgroundTransparency = (1)
startpoint.TextTransparency = (1) -- Only have this line if it is a TextLabel or a TextBox
local endPoint = {}
endPoint.BackgroundTransparency = (0)
endPoint.TextTransparency = (0) -- Only have this line if it is a TextLabel or a TextBox
Now that we have all the variables, it is time to write an event that will trigger the tween.
Something like this would work.
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if msg == "Fade" then
--Code
end
end)
Alright. Now we just need to call the tween.
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if msg == "Fade" then
local fade = tweenservice:Create(UI, info, endPoint)
fade:Play()
end
end)
That should be it! Now lets put it all together.
local tweenservice = game:GetService("TweenService")
local UI = script.Parent
local info = TweenInfo.new(
3, -- Time it takes to fade
Enum.EasingStyle.Linear -- Type of transition
)
local startpoint = {}
startpoint.BackgroundTransparency = (1)
local endPoint = {}
endPoint.BackgroundTransparency = (0)
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if msg == "Fade" then
local fade = tweenservice:Create(UI, info, endPoint)
fade:Play()
end
end)
Note: This must be a local script and the parent must be the UI. Hope this Helped!