Tween everything inside a frame: Is it possible?

Hello! I’m trying to make a sidebar that tweens out, although one problem: it doesnt tween the buttons inside:
I have this script done.

local TweenService = game:GetService("TweenService")

local frame = script.Parent.sidebar
local easteregg = script.Parent.sidebar.eastereggbutton
local welcome = script.Parent.sidebar.welcomebutton

local start_size = frame.Size
local goal_size = UDim2.new(0, 97, 0, 398)
local tweentime = 0.2


local info = TweenInfo.new(
	tweentime,
	Enum.EasingStyle.Circular,
	Enum.EasingDirection.Out,
	0,
	false,
	0

)



local mouseEnterTween = TweenService:Create(frame, info, {Size = goal_size})
local mouseLeaveTween = TweenService:Create(frame, info, {Size = start_size})



frame.MouseEnter:Connect(function()
	mouseEnterTween:Play()
end)

frame.MouseLeave:Connect(function()
	mouseLeaveTween:Play()
end)

the textbuttons are the 3rd and 4th variables, or

local easteregg = script.Parent.sidebar.eastereggbutton
local welcome = script.Parent.sidebar.welcomebutton

Anyone know how i’d make it also tween the other buttons? Thanks! :happy1:

local mouseEnterTween
local mouseLeaveTween

function CancelAllTweens()
	pcall(function()
		mouseEnterTween:Cancel()
		mouseEnterTween = nil
	end)
	pcall(function()
		mouseLeaveTween:Cancel()
		mouseLeaveTween = nil
	end)
end


frame.MouseEnter:Connect(function()
	CancelAllTweens()
	mouseEnterTween = TweenService:Create(frame, info, {Size = goal_size})
	mouseEnterTween:Play()
end)

frame.MouseLeave:Connect(function()
	CancelAllTweens()
	mouseLeaveTween = TweenService:Create(frame, info, {Size = start_size})
	mouseLeaveTween:Play()
end)

I’ve checked, I’ve got work to do.

Just create tweens for those buttons which have directly proportional animations to that of the frame (same properties, same offset ratios) and then play those tweens when the client’s mouse cursor hovers over the “Frame” instance.

Tweens play in their own threads of execution so you don’t need to worry about creating additional threads to handle them.

I know I am very late but I have created a simple function that solves your problem. I’m hoping that other people coming across this post can use my code as a reference.

local function TweenTransparncy(InstanceGui,TransparncyGoal,Time) 
	local tweeninfo = TweenInfo.new(
		Time,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0
		
	)
	
	local tween = TweenService:Create(InstanceGui,tweeninfo,{Transparency = TransparncyGoal})
	tween:Play()

	for _,Descendant in pairs(InstanceGui:GetDescendants()) do
		if Descendant:IsA("TextLabel") or Descendant:IsA("TextButton") or  Descendant:IsA("Frame") then
			local tween = TweenService:Create(Descendant,tweeninfo,{Transparency = TransparncyGoal})
				tween:Play()
			end
		end

end

TweenTransparncy(StartMenu,1,1)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.