Are there any syntax errors with this?

Hello! I am trying to create a “Find The” game on Roblox. The index (GUI) for the badges in the game cannot switch between the pages.

The code’s intent is to be able to go between different frames (pages of the index) with a variable called pagenumber that should change the page the player is on depending on what number it is.
I am not getting any error messages for this script.

Thank you for reading this!

Code here:

-- local player = game.Players.LocalPlayer
local screengui = player.PlayerGui.ScreenGui
local backbutton = screengui.BackButton
local forwardbutton = screengui.ForwardButton
local pagenumber = 1
local page1 = screengui.Index
local page2 = screengui.Index2

forwardbutton.MouseButton1Click:Connect(function()
	pagenumber = pagenumber + 1
end)

backbutton.MouseButton1Click:Connect(function()
	if pagenumber > 0 then
	pagenumber = pagenumber - 1
	end
end)

if pagenumber == 1 then
	page1.Visible = true
	page2.Visible = false
elseif pagenumber == 2 then
	page1.Visible = false
	page2.Visible = true
end



So @hfhfvvheh you want to make a book with pages that show badges the player has gotten?

Yes (in part), this is a picture of the index:

1 Like

The forward button does not send the player to the second Frame for some reason

1 Like

This code is not connected to any callback and it’s never going to run.

So you should move it in the forward button mouse click callback like this:

forwardbutton.MouseButton1Click:Connect(function()
	pagenumber = pagenumber + 1

        if pagenumber == 1 then
	    page1.Visible = true
	    page2.Visible = false
        elseif pagenumber == 2 then
	    page1.Visible = false
	    page2.Visible = true
        end
end)
1 Like

Thank you so much! I will try this for the GUI

The forward and back buttons will disappear even though they are not in a frame, could anything else be broken in the code?

Wait nevermind it’s just that the second frame is over the buttons lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.