Further In-Depth of the Title: How can I properly Calculate the Positioning of a GUI so that it does not end up going out of Position?
As the Title says, I am having trouble finding a Calculation to prevent my 'CmdsGui' function from going past a certain limit, however, when I attempt to, it only moves slightly, and doesn't respond anymore.
Sadly, I can not provide any Output because there is no Error present, however, I think I made Errors in my Calculations, because, as stated before, it only moves slightly, then does not respond anymore.
I have only provided a Snippet of the code due to the code being 31 pages long, and looking very, very, very messy, however, this Snippet of the code is where it is not working:
local NumberOfCommands = 136
local num2 = 0;
local UP = false;
local DOWN = false;
-- INFORMATION --
local Arrow --Arrow is the GUI that you click that moves the GUI upward
local Arrow2 --Arrow2 is the second GUI that you click that moves the GUI downward
local Frame2 --Frame2 is the Positioner for the Commands to move Up and Down
Arrow.MouseButton1Down:connect(function()
UP = true DOWN = false
Arrow.MouseButton1Up:connect(function() UP = false end)
repeat wait(1/13.37)
if Frame2.Position.Y.Scale >= 0.1 then break end
num2 = -0.1
Frame2:TweenPosition(UDim2.new(0,0,0.5*num2,0),"Out","Quad",1/13.37,true)
until not UP
end)
Arrow2.MouseButton1Down:connect(function()
UP = false DOWN = true
Arrow2.MouseButton1Up:connect(function() DOWN = false end)
repeat wait(1/13.37)
if Frame2.Position.Y.Scale >= 0.3-((NumberOfCommands-1)) then break end
num2 = 0.1
Frame2:TweenPosition(UDim2.new(0,0,0.5*num2,0),"Out","Quad",1/13.37,true)
until not DOWN
end)
Sorry if it sounds like I am being Picky or Rude, I have been trying to figure this out for an Hour now, but, if I need to post the entire code, just let me know.
!EDIT!
This is the Entire code, as requested;
local NumberOfCommands = 136
function CmdsGui() --I know, messy ;-;
local num = 0; local num2 = 0; local UP = false; local DOWN = false;
local CMDS = Instance.new("ScreenGui") CMDS.Name = "CMDS"
local Dragger = Instance.new("TextButton",CMDS) Dragger.Name = "Drag" Dragger.Draggable = true Dragger.BackgroundTransparency = 1 Dragger.Position = UDim2.new(0.4,0,0.2,0) Dragger.Text = "" Dragger.Size = UDim2.new(0.4,0,0.15,0)
local Frame = Instance.new("Frame",Dragger) Frame.Name = "Displayer" Frame.Size = UDim2.new(1,0,2,0) Frame.Position = UDim2.new(0,0,0.3,0) Frame.ClipsDescendants = true Frame.BackgroundColor3 = Color3.new(0/255,0/255,0/255) Frame.BorderColor3 = Color3.new(0/255,0/255,0/255)
local Frame2 = Frame:Clone() Frame2.Name = "CmdsDisplayer" Frame2.Position = UDim2.new(0,0,0,0) Frame2.Size = UDim2.new(1,0,0.1,0) Frame2.Parent = Frame Frame2.ClipsDescendants = false
local Cmd = Instance.new("TextLabel") Cmd.Size = UDim2.new(1,0,1,0) Cmd.TextColor3 = Color3.new(0/255,0/255,0/255) Cmd.TextStrokeColor3 = Color3.new(0/255,0/255,0/255) Cmd.TextWrapped = true Cmd.TextScaled = false Cmd.Name = "Cmd" Cmd.Text = "" Cmd.TextColor3 = Color3.new(255/255,255/255,255/255) Cmd.TextStrokeColor3 = Color3.new(255/255,255/255,255/255) Cmd.BorderColor3 = Color3.new(0/255,0/255,0/255) Cmd.BackgroundColor3 = Color3.new(0/255,0/255,0/255) Cmd.TextStrokeTransparency = 0.8
local Arrow = Instance.new("TextButton",Dragger) Arrow.Text = "/\\" Arrow.Name = "UP" Arrow.Position = UDim2.new(-0.1,0,0.3,0) Arrow.Size = UDim2.new(0.1,0,0.5,0) Arrow.TextWrapped = true Arrow.TextScaled = false Arrow.TextColor3 = Color3.new(255/255,255/255,255/255) Arrow.TextStrokeColor3 = Color3.new(255/255,255/255,255/255) Arrow.BackgroundColor3 = Color3.new(0/255,0/255,0/255) Arrow.BorderColor3 = Color3.new(0/255,0/255,0/255) Arrow.TextStrokeTransparency = 0.8
local Arrow2 = Arrow:Clone() Arrow2.Text = "\\/" Arrow2.Name = "DOWN" Arrow2.Position = UDim2.new(-0.1,0,0.8,0) Arrow2.Parent = Dragger
local Exit = Arrow:Clone() Exit.Text = "X" Exit.Name = "EXIT" Exit.Position = UDim2.new(-0.1,0,-0.2,0) Exit.Parent = Dragger
Arrow.MouseButton1Down:connect(function()
UP = true DOWN = false
Arrow.MouseButton1Up:connect(function() UP = false end)
repeat wait(1/13.37)
if Frame2.Position.Y.Scale >= 0.1 then break end
num2 = -0.1
Frame2:TweenPosition(UDim2.new(0,0,0.5*num2,0),"Out","Quad",1/13.37,true)
until not UP
end)
Arrow2.MouseButton1Down:connect(function()
UP = false DOWN = true
Arrow2.MouseButton1Up:connect(function() DOWN = false end)
repeat wait(1/13.37)
if Frame2.Position.Y.Scale >= 0.3-((NumberOfCommands-1)) then break end
num2 = 0.1
Frame2:TweenPosition(UDim2.new(0,0,0.5*num2,0),"Out","Quad",1/13.37,true)
until not DOWN
end)
return CMDS,Frame2,Cmd,num
end

4 comments
Are you sure you want me to post the entire code? I will, however, I have to warn you, it looks Super messy.
You can post the code or upload the roblox studio project and I can have a look at it
Alright, I have posted the entire code.
Sorry but I could not fix it 100%