local nextbutton = script.Parent local prevbutton = script.Parent.Parent.Backward local view = 0 if view == 0 then nextbutton.MouseButton1Click:connect(function() view = 1 print(view) print("page 2") script.Parent.Parent.BasicInfo.Visible = false script.Parent.Parent.Face.Visible = true script.Parent.Parent.Backward.Visible = true end) if view == 1 then script.Parent.Parent.Backward.MouseButton1Click:connect(function() view = 0 print(view) print("page 1") script.Parent.Parent.BasicInfo.Visible = true script.Parent.Parent.Face.Visible = false script.Parent.Parent.Backward.Visible = false end) end end
This script only functions properly when the second if statement is <= 1, but I need it to only equal 1. I checked the output to make sure that this variable is one upon pressing it, but it doesn't do anything.
Your script isn't working, because it checks what 'view' equals at the start of the script. It's not inside either function, so it won't update if you update the view variable.
This is easy to fix, however.
local nextbutton = script.Parent local backbutton = script.Parent.Parent.Backward local info = script.Parent.Parent.BasicInfo local face = script.Parent.Parent.Face local view = 0 nextbutton.MouseButton1Click:connect(function() if view == 0 then view = 1 print(view) print("page 2") info.Visible = false face.Visible = true backbutton.Visible = true end end) backbutton.MouseButton1Click:connect(function() if view == 1 then view = 0 print(view) print("page 1") info.Visible = true face.Visible = false backbutton.Visible = false end end)
As you can see, each time you click the button, it will check what view equals. That should be all you need to know.