I need help with UI Overlapping

Hi, I am currently looking for help because I need to make only one UI appear at a time and I was hoping for a simple method to do this. Because currently, i can open lots of UI’s at one time.

(video)

1 Like

Maybe this will help you:

local tweenService = game:GetService("TweenService")
local mainFrame = script.Parent.Parent.Parent.SeachGui.Main
local AccFrame = game.Players.LocalPlayer:WaitForChild("PlayerGui").ScreenGui.AccFrame
local sound = script.Parent.Sound

local startPosition = UDim2.new(0.5, 0, -1, 0) -- Starting position (above the screen)
local targetPosition = UDim2.new(0.5, 0, 0.5, 0) -- Target position (position when visible)
local easingDirection = Enum.EasingDirection.Out -- Easing direction
local easingStyle = Enum.EasingStyle.Back -- Easing style
local duration = 1 -- Duration of tween

local tweenInfo = TweenInfo.new(duration, easingStyle, easingDirection) -- Tween information

local isDown = false -- Flag to track if frame is currently down
	
local currentFrame = nil

-- Function to toggle frame position
local function toggleFramePosition(frame)
	if currentFrame == frame then
		-- If the same frame is clicked again, hide it
		tweenService:Create(frame, tweenInfo, {Position = startPosition}):Play()
		currentFrame = nil
	else
		-- Hide the currently shown frame if any
		if currentFrame then
			tweenService:Create(currentFrame, tweenInfo, {Position = startPosition}):Play()
		end
		-- Show the clicked frame
		tweenService:Create(frame, tweenInfo, {Position = targetPosition}):Play()
		currentFrame = frame
	end

	sound:Play() -- Play sound
end

mainFrame.Parent.Open.MouseButton1Click:Connect(function()
	toggleFramePosition(mainFrame)
end)

script.Parent.MouseButton1Click:Connect(function()
	toggleFramePosition(AccFrame)
end)

Starter Gui:

Screenshot 2024-04-21 135457

Video of how it looks like in my game:

1 Like

Thanks, I will try this now, I’ll let you know of the result

After an hour of coding I managed thanks to you, Thank you so much for this script it helped a lot!

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