|
I can assure you all variables are accounted for.
DTN is the variable that the first for loop uses to create a fake "Max Number"
for the page counter later on.
To make a long story short, everything works just fine except for the MouseButton1Down and MouseButton1Up functions. When your mouse left clicks a TextButton, an ImageLabel inside the TextButton (with ClipsDescendants on) moves around, allowing me to use a sprite sheet for the button animations instead of multiple assets.
However, the animation only seems to work once. In order to make it works again I am required to move the mouse a tiny bit first. I don't actually have to leave the button and re-enter it but I do have to move it slightly to make the clicking animation play again.
I have no clue why it's behaving that way, though. They have no special conditions, and therefore should work just fine.
local DT = Book["Dual Towers"]:GetChildren()
for i = 1, #DT do if DT[i].ClassName == "Frame" then
DTN = DTN + 1; DT[i].Visible = false end end
local LDT = Book["Dual Towers"].PageNum.Left
local RDT = Book["Dual Towers"].PageNum.Right
local NDT = Book["Dual Towers"].PageNum.Num
DT[DTNum].Visible = true; NDT.Text = "1/" .. DTN
LDT.MouseButton1Down:connect(function()
if LDT.Img.Position ~= UDim2.new(0, 0, -3, 0) then
LDT.Img.Position = UDim2.new(0, 0, -1, 0) end end)
LDT.MouseButton1Up:connect(function()
if LDT.Img.Position ~= UDim2.new(0, 0, -3, 0) then
LDT.Img.Position = UDim2.new(0, 0, -2, 0) end end)
LDT.MouseEnter:connect(function()
if LDT.Img.Position ~= UDim2.new(0, 0, -3, 0) then
LDT.Img.Position = UDim2.new(0, 0, -2, 0) end end)
LDT.MouseLeave:connect(function()
if LDT.Img.Position ~= UDim2.new(0, 0, -3, 0) then
LDT.Img.Position = UDim2.new(0, 0, 0, 0) end end)
LDT.MouseButton1Click:connect(function()
if LDT.Img.Position ~= UDim2.new(0, 0, -3, 0) then
if DTNum == DTN then DTNum = DTNum - 1
RDT.Img.Position = UDim2.new(-1, 0, -2, 0)
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
elseif DTNum > 2 then DTNum = DTNum - 1
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
elseif DTNum == 2 then DTNum = DTNum - 1
LDT.Img.Position = UDim2.new(0, 0, -3, 0)
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
end end end)
RDT.MouseButton1Down:connect(function()
if RDT.Img.Position ~= UDim2.new(-1, 0, -3, 0) then
RDT.Img.Position = UDim2.new(-1, 0, -1, 0) end end)
RDT.MouseButton1Up:connect(function()
if RDT.Img.Position ~= UDim2.new(-1, 0, -3, 0) then
RDT.Img.Position = UDim2.new(-1, 0, -2, 0) end end)
RDT.MouseEnter:connect(function()
if RDT.Img.Position ~= UDim2.new(-1, 0, -3, 0) then
RDT.Img.Position = UDim2.new(-1, 0, -2, 0) end end)
RDT.MouseLeave:connect(function()
if RDT.Img.Position ~= UDim2.new(-1, 0, -3, 0) then
RDT.Img.Position = UDim2.new(-1, 0, 0, 0) end end)
RDT.MouseButton1Click:connect(function()
if RDT.Img.Position ~= UDim2.new(-1, 0, -3, 0) then
if DTNum == 1 then DTNum = DTNum + 1
LDT.Img.Position = UDim2.new(0, 0, -2, 0)
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
elseif DTNum < (DTN-1) then DTNum = DTNum + 1
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
elseif DTNum == (DTN-1) then DTNum = DTNum + 1
RDT.Img.Position = UDim2.new(-1, 0, -3, 0)
for i = 1, #DT do if DT[i]:IsA("Frame") then
DT[i].Visible = false end end
DT[DTNum].Visible = true
NDT.Text = DTNum .. "/" .. DTN
end end end) |