I’m trying to make a ‘fade’ menu. Right now, I think it’s good, but the problem is I want the button, text, and blur to fade out. I already got help to make the music fade out, but I don’t know how to do the other ones. I even tried copy pasting the script under it, and that didn’t go very well, since it did literally nothing at all. Also, I put a wait under it cause I thought maybe it was just deleting it before it could play the fade animation, but that did nothing either. (Just made a useless delay) Here’s the script:
local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local Mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
local defaultCframe = camera.CFrame
local view = 150
local blur = game.Lighting.Blur
blur.Size = 13
function updateCamera()
camera.CFrame = game.Workspace.MenuCamera.CFrame
end
game:GetService("RunService").RenderStepped:Connect(updateCamera)
script.Parent.Frame.Play.MouseButton1Click:Connect(function()
wait (0.2)
blur.Size = 5
camera.CameraType = Enum.CameraType.Custom
script.Parent.Frame:Destroy()
local TweenService = game:GetService("TweenService")
local t1 = TweenService:Create(game.SoundService.MenuMusic, TweenInfo.new(2), {Volume = 0})
t1:Play()
script:Destroy()
end)
For the text part of things, it works great. Except for the button, I use a UIGradient so I can have color and a rounded button both, but with a rounded button from the Roblox styles, I can’t seem to change the background transparency.
local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local Mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
local defaultCframe = camera.CFrame
local view = 150
local blur = game.Lighting.Blur
blur.Size = 13
function updateCamera()
camera.CFrame = game.Workspace.MenuCamera.CFrame
end
game:GetService("RunService").RenderStepped:Connect(updateCamera)
script.Parent.Frame.Play.MouseButton1Click:Connect(function()
wait (0.2)
blur.Size = 5
camera.CameraType = Enum.CameraType.Custom
local TweenService = game:GetService("TweenService")
local t1 = TweenService:Create(game.SoundService.MenuMusic, TweenInfo.new(2), {Volume = 0})
local t2 = TweenService:Create(player.PlayerGui.MenuGUI.Frame.TextLabel, TweenInfo.new(2), {TextTransparency = 1, BackgroundTransparency = 1})
local t3 = TweenService:Create(player.PlayerGui.MenuGUI.Frame.Play, TweenInfo.new(2), {TextTransparency = 1, BackgroundTransparency = 1})
t1:Play()
t2:Play()
t3:Play()
wait(5)
script.Parent.Frame:Destroy()
script:Destroy()
end)
That’s because UIGradient BackgroundTransparency is a NumberSequence which isn’t supported by TweenService. To tween that you will need to create a new NumberSequence with the data tweened to where you want it and set BackgroundTransparency to that. It would look something like this (completely untested, but it’s the general idea)
local fadeTime = 2
local fadeStart = nil
local function startFade()
fadeStart = tick()
end
function BindWithRunService()
if fadeStart then
local a = math.min((tick()-fadeStart)/fadeTime,1)
local ns = NumberSequence.new(a)
UIGradient.BackgroundTransparency = ns
if tick()-fadeStart-fadeTime <=0 then fadeStart = nil end
end
end
And this code wouldn’t work if you have the transparency anything that isn’t constant since it would set the transparency to constant. If you have actually set the NumberSequence to do a gradient transparency, you will need to account for that and set the NumberSequenceKeyPoints yourself rather than letting the .new handle it.
Sorry for the very late response, I’ve been busy. Anyways, I’ve tested the code and I’m really confused. I probably put something there that isn’t meant to be there. It fades everything except the gradient, which just stays there until all the other stuff fades.
local player = game.Players.LocalPlayer
local character = player.CharacterAdded
local Mouse = player:GetMouse()
local camera = game.Workspace.CurrentCamera
local defaultCframe = camera.CFrame
local view = 150
local blur = game.Lighting.Blur
blur.Size = 13
function updateCamera()
camera.CFrame = game.Workspace.MenuCamera.CFrame
end
game:GetService("RunService").RenderStepped:Connect(updateCamera)
script.Parent.Frame.Play.MouseButton1Click:Connect(function()
wait (0.2)
blur.Size = 5
camera.CameraType = Enum.CameraType.Custom
local TweenService = game:GetService("TweenService")
local t1 = TweenService:Create(game.SoundService.MenuMusic, TweenInfo.new(2), {Volume = 0})
local t2 = TweenService:Create(player.PlayerGui.MenuGUI.Frame.TextLabel, TweenInfo.new(2), {TextTransparency = 1, BackgroundTransparency = 1})
local t3 = TweenService:Create(player.PlayerGui.MenuGUI.Frame.Play, TweenInfo.new(2), {TextTransparency = 1, BackgroundTransparency = 1})
local fadeTime = 2
local fadeStart = 0
local function startFade()
fadeStart = tick()
end
local function BindWithRunService()
if fadeStart then
local a = math.min((tick()-fadeStart)/fadeTime, 1)
local ns = NumberSequence.new(a)
player.PlayerGui.MenuGUI.Frame.Play.UIGradient.Transparency = ns
if tick()-fadeStart-fadeTime <=0 then fadeStart = 0 end
end
end
t1:Play()
t2:Play()
t3:Play()
wait(3)
script.Parent.Frame:Destroy()
script:Destroy()
end)