Hey, I had a question. I have a pretty large script rn and I questioned myself is there a way too make it shorter and since Im still a complete beginner idk what the best way is to do that
wait(2)
local cs = game:GetService("SoundService").SFX.Click
local Operator = script.Parent.Operator.Value
local function Tweening(frame, location)
frame:TweenPosition(UDim2.new(location), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Back, --Style
1, --Time
false) --again?
end
local HomeFrame = script.Parent.Parent.BaseFrameHome
local SettingsFrame = script.Parent.Parent.BaseFrameSettings
local DeployFrame = script.Parent.Parent.BaseFrameDeploy
local StoreFrame = script.Parent.Parent.BaseFrameStore
local CreditsFrame = script.Parent.Parent.BaseFrameCredits
local ServersFrame = script.Parent.Parent.BaseFrameServers
local OverheadFrame = script.Parent
local HomeButton = script.Parent.Home
local StoreButton = script.Parent.Store
local ServersButton = script.Parent.Servers
local SettingsButton = script.Parent.Settings
local CreditsButton = script.Parent.Credits
local DeployButton = script.Parent.Parent.BaseFrameHome.DeployFrame.Detector
local ReturnDeployToHome = DeployFrame.ReturnFrame.Detector
local SettingsButton2 = HomeFrame.SettingsFrame.Detector
local CreditsButton2 = HomeFrame.CreditsFrame.Detector
local StoreButton2 = HomeFrame.StoreFrame.Detector
local function ToHome()
if Operator == true then
print("in session")
else
Operator = true
Tweening(HomeFrame, 0,0,0,0)
Tweening(SettingsFrame, 2,0,0,0 )
Tweening(CreditsFrame, 4,0,0,0)
Tweening(StoreFrame, -2,0,0,0)
Tweening(ServersFrame, -4,0,0,0)
cs:Play()
wait(1)
Operator = false
end
end
local function ToSettings()
if Operator == true then
print("in session")
else
Operator = true
Tweening(HomeFrame, -2,0,0,0)
Tweening(SettingsFrame, 0,0,0,0 )
Tweening(CreditsFrame, 2,0,0,0)
Tweening(StoreFrame, -4,0,0,0)
Tweening(ServersFrame, -6,0,0,0)
cs:Play()
wait(1)
Operator = false
end
end
local function ToCredits()
if Operator == true then
print("in session")
else
Operator = true
Tweening(HomeFrame, -4,0,0,0)
Tweening(SettingsFrame, -2,0,0,0 )
Tweening(CreditsFrame, 0,0,0,0)
Tweening(StoreFrame, -6,0,0,0)
Tweening(ServersFrame, -8,0,0,0)
cs:Play()
wait(1)
Operator = false
end
end
local function ToStore()
if Operator == true then
print("in session")
else
Operator = true
Tweening(HomeFrame, 2,0,0,0)
Tweening(SettingsFrame, 4,0,0,0 )
Tweening(CreditsFrame, 6,0,0,0)
Tweening(StoreFrame, 0,0,0,0)
Tweening(ServersFrame, -2,0,0,0)
cs:Play()
wait(1)
Operator = false
end
end
local function ToServer()
if Operator == true then
print("in session")
else
Operator = true
Tweening(HomeFrame, 4,0,0,0)
Tweening(SettingsFrame, 6,0,0,0 )
Tweening(CreditsFrame, 8,0,0,0)
Tweening(StoreFrame, 2,0,0,0)
Tweening(ServersFrame, 0,0,0,0)
cs:Play()
wait(1)
Operator = false
end
end
local function ToDeploy()
if Operator == true then
print("in session")
else
Operator = true
HomeFrame:TweenPosition(UDim2.new(0, 0,-2, 0), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Back, --Style
1, --Time
false) --again?
OverheadFrame:TweenPosition(UDim2.new(0, 0,-1, 0), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Linear, --Style
1, --Time
false) --again?
DeployFrame:TweenPosition(UDim2.new(0, 0,0, 0), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Back, --Style
1, --Time
false) --again?
cs:Play()
wait(1)
Operator = false
end
end
local function DeployToHome()
if Operator == true then
print("in session")
else
DeployFrame:TweenPosition(UDim2.new(0, 0,2, 0), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Back, --Style
1, --Time
false) --again?
OverheadFrame:TweenPosition(UDim2.new(0, 0,0, 0), --position
Enum.EasingDirection.Out, --Direction
Enum.EasingStyle.Linear, --Style
1, --Time
false) --again?
ToHome()
end
end
ReturnDeployToHome.MouseButton1Up:Connect(function()
DeployToHome()
end)
DeployButton.MouseButton1Up:Connect(function()
ToDeploy()
end)
HomeButton.MouseButton1Up:Connect(function()
ToHome()
end)
SettingsButton.MouseButton1Up:Connect(function()
ToSettings()
end)
SettingsButton2.MouseButton1Up:Connect(function()
ToSettings()
end)
CreditsButton.MouseButton1Up:Connect(function()
ToCredits()
end)
CreditsButton2.MouseButton1Up:Connect(function()
ToCredits()
end)
StoreButton.MouseButton1Up:Connect(function()
ToStore()
end)
StoreButton2.MouseButton1Up:Connect(function()
ToStore()
end)
ServersButton.MouseButton1Up:Connect(function()
ToServer()
end)