My gui is made to switch between 2 pages when someone clicks next/previous. This is just added on to my shop gui, which isn't relevant.
This works, but for some reason I need to click twice when switching between pages. This can cause confusion, and people may think it's broken.
npopen = false script.Parent.MouseButton1Down:connect(function() if npopen == false then npopen = true script.Parent.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255) script.Parent.Parent.Previous.BackgroundColor3 = Color3.new(0, 0, 0) script.Parent.Parent.NextPage.Visible = true elseif npopen == true then npopen = false print('already open') end end)
local popen = false script.Parent.MouseButton1Down:connect(function() if popen == false then popen = true script.Parent.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255) script.Parent.Parent.Next.BackgroundColor3 = Color3.new(0, 0, 0) script.Parent.Parent.NextPage.Visible = false elseif popen == true then popen = false print('already closed') end end)
http://prntscr.com/7mcvak
http://www.roblox.com/shopthing-item?id=263133147
If it is just changing the page, why do you have a debounce? Just remove the debounce and you should be fine :)
Your problem is very simple. When you set your isNext
variable, you already put .Value
. Therefore, it's going to save the value what it currently is. In other words, it won't keep updating the variable, whenever the BoolValue changes. The way to fix this is by removing .Value
from where you declare the isNext
variable, and whenever you're comparing it or setting it as a new value, add .Value
. Here are your scripts:
wait(2) local isNext = script.Parent.IsNext script.Parent.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then if isNext.Value == true then script.Parent.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255) script.Parent.Parent.Previous.BackgroundColor3 = Color3.new(0, 0, 0) script.Parent.Parent.NextPage.Visible = true isNext.Value = false elseif isNext.Value == false then print('Already open') end end end)
wait(2) local isNext = script.Parent.IsNext script.Parent.InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then if isNext.Value == false then script.Parent.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255) script.Parent.Parent.Next.BackgroundColor3 = Color3.new(0, 0, 0) script.Parent.Parent.NextPage.Visible = false isNext.Value = true elseif isNext.Value == true then print('Already closed') end end end)