//
Hey there, my name is Keegan, an aspiring programmer here on Roblox.
I know that this current script works, but I was wondering if there is a more efficient way to do it.
//
local PetsButton = script.Parent.ButtonFrame.PetsButton
local StoreButton = script.Parent.ButtonFrame.StoreButton
local PetsFrame = script.Parent.MainFrame.PetsFrame
local StoreFrame = script.Parent.MainFrame.StoreFrame
local PetsLine = script.Parent.MainFrame.PetsFrame.Text.ImageLabel
local StoreLine = script.Parent.MainFrame.StoreFrame.Text.ImageLabel
local PetsOpen = script.Parent.PetsValue
local StoreOpen = script.Parent.StoreValue
local PetsClose = script.Parent.MainFrame.PetsFrame.CloseButton.TextButton
local StoreClose = script.Parent.MainFrame.StoreFrame.CloseButton.TextButton
local Camera = game:GetService("Workspace").CurrentCamera
local Blur = Instance.new("BlurEffect", Camera)
local debounce = true
Blur.Size = 0
local function closeblur()
if debounce == false then
debounce = true
for i = 1,10 do
Blur.Size = Blur.Size - 1
wait(.01)
end
end
end
local function openblur()
if debounce == true then
debounce = false
for i = 1,10 do
Blur.Size = Blur.Size + 1
wait(.01)
end
end
end
PetsButton.MouseButton1Click:Connect(function()
if PetsOpen.Value == false then
StoreOpen.Value = false
PetsOpen.Value = true
PetsFrame:TweenPosition(UDim2.new(.6, 0, .5, 0), 'Out', 'Elastic', 1, true)
StoreFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
PetsLine:TweenSize(UDim2.new(.5, 0, .01, 0), 'Out', 'Quint', 1.5, true)
StoreLine:TweenSize(UDim2.new(0, 0, .01, 0), 'Out', 'Quint', 1.5, true)
openblur()
else
if PetsOpen.Value == true then
PetsOpen.Value = false
PetsFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
PetsLine:TweenSize(UDim2.new(0, 0, .01, 0), 'In', 'Quint', .1, true)
closeblur()
print("1")
end
end
end)
PetsClose.MouseButton1Click:Connect(function()
if PetsOpen.Value == true then
PetsOpen.Value = false
PetsFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
PetsLine:TweenSize(UDim2.new(0, 0, .01, 0), 'In', 'Quint', .1, true)
closeblur()
print("2")
end
end)
StoreButton.MouseButton1Click:Connect(function()
if StoreOpen.Value == false then
PetsOpen.Value = false
StoreOpen.Value = true
StoreFrame:TweenPosition(UDim2.new(.6, 0, .5, 0), 'Out', 'Elastic', 1, true)
PetsFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
StoreLine:TweenSize(UDim2.new(.5, 0, .01, 0), 'Out', 'Quint', 1.5, true)
PetsLine:TweenSize(UDim2.new(0, 0, .01, 0), 'In', 'Quint', .1, true)
openblur()
else
if StoreOpen.Value == true then
StoreOpen.Value = false
StoreFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
StoreLine:TweenSize(UDim2.new(0, 0, .01, 0), 'In', 'Quint', .1, true)
print("3")
closeblur()
end
end
end)
StoreClose.MouseButton1Click:Connect(function()
if StoreOpen.Value == true then
StoreOpen.Value = false
StoreFrame:TweenPosition(UDim2.new(.6, 0, 1.5, 0), 'Out', 'Elastic', 1, true)
StoreLine:TweenSize(UDim2.new(0, 0, .01, 0), 'Out', 'Quint', 1.5, true)
closeblur()
print("4")
end
end)
//
Script explanation: The UI is to Tween from the bottom up when opened (on click), During the UI opening, a blur is to happen in the background to emphasize the UI. Once another UI opens, the one that was currently on the screen tweens to the bottom, and the new clicked one tweens to the same position as the previous one. The “x” in the top right of both UI’s close the currently open one.
//
In-game representation: https://gyazo.com/5c5fe9d9c55a7acf00cfdd9bd56434cc
//
I am making this thread to try and improve my skills in scripting to become a more efficient scripter. I thank you very much for taking the time to view this thread, have an amazing rest of your day!
(I know there are more efficient ways, but being a beginner in scripting, I want to hear your guys’ imputs.)
//
- Keegan, C6T9