i am working on an ui of book alomst done with it
the issue here is that the book have two section1 and section2 section 1 and two both have a child and that child has a name of clone and that clone is updateing with the page
the section1 clone works fine but the section2 clone doesnt work as supposed to
section2 clone not updateing at all
local Frame = script.Parent
local Seciton1 = Frame.Seciton1
local Seciton2 = Frame.Seciton2
local NextButton = Frame.Next
local BackButton = Frame.Back
local FrameModle = script.Frame
local Page = Frame.Page
local rbx = "rbxassetid://"
local Pages = {
Page1 = {Frame1 = {
text = "جبالي اجا و سلمى",
ImageId = rbx.."18222933997",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.015, 0,0.086, 0)
},Frame2 = {
text ="جديس",
ImageId = rbx.."18222773535",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.066, 0,0.389, 0)
}},
Page2 = {Frame1 = {
text = "ddddddddd",
ImageId = rbx.."631727248",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.015, 0,0.086, 0)
},Frame2 = {
text ="جديس2",
ImageId = rbx.."3333333",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.066, 0,0.389, 0)
}},
Page3 = {Frame1 = {
text = "page3",
ImageId = rbx.."9180622665",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.015, 0,0.086, 0)
},Frame2 = {
text ="جديس2",
ImageId = rbx.."3333333",
Size = UDim2.new(0.944, 0,0.505, 0),
Position = UDim2.new(0.066, 0,0.389, 0)
}},
}
local legnthOfDictionary = function(dictionary)
local HowManyItems = 0
for i in pairs(dictionary) do
HowManyItems += 1
end
return HowManyItems
end
local MaxPage = legnthOfDictionary(Pages)
local CurrentPage = 1
Page.Text = "صفحه"..tostring(MaxPage).."/"..tostring(CurrentPage)
print(Page)
local Updateing = function(PageFrame,key,IsItFirstTime)
print(PageFrame)
Page.Text = "صفحه"..tostring(MaxPage).."/"..tostring(CurrentPage)
if Seciton1:FindFirstChild("Clone") and not IsItFirstTime then
local Clone = Seciton1:FindFirstChild("Clone")
Clone.Position = PageFrame.Position
Clone.Size = PageFrame.Size
Clone:WaitForChild("image").Image = PageFrame.ImageId
Clone:WaitForChild("Name").Text = PageFrame.text
print("Clone1 Edited, ",Clone)
return
elseif Seciton2:FindFirstChild("Clone") and not IsItFirstTime then
local Clone = Seciton2:FindFirstChild("Clone")
print(Clone,"Edited?2")
Clone.Position = PageFrame.Position
Clone.Size = PageFrame.Size
Clone:WaitForChild("image").Image = PageFrame.ImageId
Clone:WaitForChild("Name").Text = PageFrame.text
print("Clone2 Edited, ",Clone)
return
end
local Clone = FrameModle:Clone()
Clone.Name = "Clone"
Clone.Position = PageFrame.Position
Clone.Size = PageFrame.Size
Clone:WaitForChild("image").Image = PageFrame.ImageId
Clone:WaitForChild("Name").Text = PageFrame.text
print(key)
if key == 1 then
Clone.Parent = Seciton1
else
Clone.Parent = Seciton2
end
end
Updateing(Pages["Page1"].Frame1,1,true)
Updateing(Pages["Page1"].Frame2,2,true)
local NextBackFunction = function(Next)
if Next then
if CurrentPage ~= MaxPage then
CurrentPage += 1
local TargetPage = Pages["Page"..CurrentPage]
for key,PageFrame in pairs(TargetPage) do
print(PageFrame)
if key == "Frame1" then
print("called from here for Seciton1")
Updateing(PageFrame,1,false)
else
print("called from here for Seciton1")
Updateing(PageFrame,2,false)
end
end
end
else
if CurrentPage ~= 1 then
CurrentPage -= 1
local TargetPage = Pages["Page"..CurrentPage]
for key,PageFrame in pairs(TargetPage) do
if key == "Frame1" then
Updateing(PageFrame,1,false)
else
Updateing(PageFrame,2,false)
end
end
end
end
end
NextButton.MouseButton1Click:Connect(function()
NextBackFunction(true)
end)
BackButton.MouseButton1Click:Connect(function()
NextBackFunction(false)
end)
--for Key,Value in pairs(Pages) do
-- for _,FramePropites in pairs(Value) do
-- end
--end