Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I need help fixing the scripting errors in my main menu script! ?

Okay, to start off I know next to nothing about Lua so I've been following a tutorial on how to make a main menu for my game and have been changing it to fit my case. SOMETHING I added broke the entire thing. Everything was going well, and it was working until I added a few lines of code that brought you to a "Trial Select" screen when you press play. I have no idea what is wrong with it or how to fix it due to not have any Lua experience and I just need some help fixing it. The scripts are below. Thank you!

The error I've been getting

"20:14:51.254 - Players.Westleys_Peaches.PlayerGui.Menu.MenuMain:143: Expected 'end' (to close 'function' at line 73), got "

Script #1 -SetGUISettings

--Services
local SG = game:GetService("StarterGui")
local SP = game:GetService("StarterPlayer")
local UIS = game:GetService("UserInputService")
local PLRS = game:GetService("Players")
local FT = 0

local function SetGUI()
	SG:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
	SG:SetCore("ResetButtonCallback",false)
	UIS.ModalEnabled = true
	print("Finished Setting GUI")
end

local Success,Error = pcall(SetGUI)

repeat
	FT = FT + 1
	wait(2)
	Success,Error = pcall(SetGUI)
until FT == 5 or Success

if FT == 5 then
	PLRS.LocalPlayer:Kick()
elseif FT~= 5 and Success then
	warn("Success")
end

Script #2 -MenuMain

wait(5)

--Services
local Tween = game:GetService("TweenService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
--SIdebar
local Sidebar = script.Parent:WaitForChild("Sidebar")
local PlayBtn = Sidebar:WaitForChild("Play")
local ShopBtn = Sidebar:WaitForChild("Shop")
local Title = Sidebar:WaitForChild("Title")

--GamePopup
local GamePopup = script.Parent:WaitForChild("GamePopup")
local Text1 = GamePopup:WaitForChild("Text1")
local Text2 = GamePopup:WaitForChild("Text2")
local Text3 = GamePopup:WaitForChild("Text3")
local Text4 = GamePopup:WaitForChild("Text4")
local Text5 = GamePopup:WaitForChild("Text5")
local Trial1 = GamePopup:WaitForChild("Trial1")
local Trial2 = GamePopup:WaitForChild("Trial2")
local Trial3 = GamePopup:WaitForChild("Trial3")
local Trial4 = GamePopup:WaitForChild("Trial4")
local Trial5 = GamePopup:WaitForChild("Trial5")
local Return = GamePopup:WaitForChild("Return")

--ShopPopup
local ShopPopup = script.Parent:WaitForChild("ShopPopup")

--Tweens 
local SlideOutSide = Tween:Create(Sidebar,TweenInfo.new(0.4,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = UDim2.new(0,0,0,0)})
local SlideInSide = Tween:Create(Sidebar,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = UDim2.new(-0.3,0,0,0)})

local HoverOverPlayBtn = Tween:Create(PlayBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.1,0)})
local LeavePlayBtn = Tween:Create(PlayBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.09,0)})

local HoverOverShopBtn = Tween:Create(ShopBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.1,0)})
local LeaveShopBtn = Tween:Create(ShopBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.09,0)})

local GamePopin = Tween:Create(GamePopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{Transparency = 0.5})

local ShopPopin = Tween:Create(ShopPopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine {Transparency = 0.5}) 
local ShopPopout = Tween:Create(ShopPopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{Transparency = 1})

local Text1In = Tween:Create(Text1,TweenInfo.new(0.3),{TextTransparency = 0})
local Text2In = Tween:Create(Text2,TweenInfo.new(0.3),{TextTransparency = 0})
local Text3In = Tween:Create(Text3,TweenInfo.new(0.3),{TextTransparency = 0})
local Text4In = Tween:Create(Text4,TweenInfo.new(0.3),{TextTransparency = 0})
local Text5In = Tween:Create(Text5,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial1In = Tween:Create(Trial1,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial2In = Tween:Create(Trial2,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial3In = Tween:Create(Trial3,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial4In = Tween:Create(Trial4,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial5In = Tween:Create(Trial5,TweenInfo.new(0.3),{TextTransparency = 0})
local ReturnIn = Tween:Create(Return,TweenInfo.new(0.3),{TextTransparency = 0})

local ShopOpen = false
local FT = 0

SlideOutSide:Play()--PlayTween

local function TeleportToGame(GameID)
  TeleportService:Teleport(GameID)
end

--PlayBtn 
PlayBtn.MouseEnter:Connect(function()
	HoverOverPlayBtn:Play()
end)
PlayBtn.MouseLeave:Connect(function()
	LeavePlayBtn:Play()
end)
PlayBtn.MouseButton1Click:Connect(function()

	GamePopin:Play()
	SlideInSide:Play()
	if ShopOpen then
	  ShopPopout:Play()
	end
	wait(0.5)
	Sidebar:Destroy()
	ShopPopup:Destroy()

 local Success, Error = pcall(function()
	TeleportToGame(4845271643)
  end)
	

  repeat
	FT = FT + 1
	wait(5)
	Success, Error = pcall(function()
	  TeleportToGame(4845271643)
    end)
  until Success or FT == 1

  if FT == 5 then
	Players.LocalPlayer:Kick("Problem Joining Game")
  elseif FT~= 5 and Success then
	warn("Success")
  end


Text1In:Play()
Text2In:Play()
Text3In:Play()
Text4In:Play()
Text5In:Play()
Trial1In:Play()
Trial2In:Play()
Trial3In:Play()
Trial4In:Play()
Trial5In:Play()
ReturnIn:Play()

--ShopBtn
ShopBtn.MouseEnter:Connect(function()
	HoverOverShopBtn:Play()
end)
ShopBtn.MouseLeave:Connect(function()
	LeaveShopBtn:Play()
end)
ShopBtn.MouseButton1Click:Connect(function()
	if not ShopOpen then
		ShopOpen = true
		ShopPopin:Play()
		wait(0.3)
		for i,v in pairs(ShopPopup:GetDescendants())do
			if v.IsA("TextLabel")then
			v.Visible = true
		  end
		end
	else
	   for i,v in pairs(ShopPopup:GetDescendants())do
		  if v.IsA("TextLabel")then
			  v.Visible = false
		  end
		end
		ShopPopout:Play()
		ShopOpen = false
		wait(0.3)
	end
end)

1 comment

0

what part of the script is broken?

1 answer

✓ Accepted answer

This is simple, you just forgot to add an end, first I will give you the code then I will explain what this is!

Script 1 is all good, script 2 is this:

wait(5)

--Services
local Tween = game:GetService("TweenService")
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
--SIdebar
local Sidebar = script.Parent:WaitForChild("Sidebar")
local PlayBtn = Sidebar:WaitForChild("Play")
local ShopBtn = Sidebar:WaitForChild("Shop")
local Title = Sidebar:WaitForChild("Title")

--GamePopup
local GamePopup = script.Parent:WaitForChild("GamePopup")
local Text1 = GamePopup:WaitForChild("Text1")
local Text2 = GamePopup:WaitForChild("Text2")
local Text3 = GamePopup:WaitForChild("Text3")
local Text4 = GamePopup:WaitForChild("Text4")
local Text5 = GamePopup:WaitForChild("Text5")
local Trial1 = GamePopup:WaitForChild("Trial1")
local Trial2 = GamePopup:WaitForChild("Trial2")
local Trial3 = GamePopup:WaitForChild("Trial3")
local Trial4 = GamePopup:WaitForChild("Trial4")
local Trial5 = GamePopup:WaitForChild("Trial5")
local Return = GamePopup:WaitForChild("Return")

--ShopPopup
local ShopPopup = script.Parent:WaitForChild("ShopPopup")

--Tweens 
local SlideOutSide = Tween:Create(Sidebar,TweenInfo.new(0.4,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = UDim2.new(0,0,0,0)})
local SlideInSide = Tween:Create(Sidebar,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = UDim2.new(-0.3,0,0,0)})

local HoverOverPlayBtn = Tween:Create(PlayBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.1,0)})
local LeavePlayBtn = Tween:Create(PlayBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.09,0)})

local HoverOverShopBtn = Tween:Create(ShopBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.1,0)})
local LeaveShopBtn = Tween:Create(ShopBtn,TweenInfo.new(0.3,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size = UDim2.new(1,0,0.09,0)})

local GamePopin = Tween:Create(GamePopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{Transparency = 0.5})

local ShopPopin = Tween:Create(ShopPopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine {Transparency = 0.5}) 
local ShopPopout = Tween:Create(ShopPopup,TweenInfo.new(0.3,Enum.EasingStyle.Sine),{Transparency = 1})

local Text1In = Tween:Create(Text1,TweenInfo.new(0.3),{TextTransparency = 0})
local Text2In = Tween:Create(Text2,TweenInfo.new(0.3),{TextTransparency = 0})
local Text3In = Tween:Create(Text3,TweenInfo.new(0.3),{TextTransparency = 0})
local Text4In = Tween:Create(Text4,TweenInfo.new(0.3),{TextTransparency = 0})
local Text5In = Tween:Create(Text5,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial1In = Tween:Create(Trial1,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial2In = Tween:Create(Trial2,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial3In = Tween:Create(Trial3,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial4In = Tween:Create(Trial4,TweenInfo.new(0.3),{TextTransparency = 0})
local Trial5In = Tween:Create(Trial5,TweenInfo.new(0.3),{TextTransparency = 0})
local ReturnIn = Tween:Create(Return,TweenInfo.new(0.3),{TextTransparency = 0})

local ShopOpen = false
local FT = 0

SlideOutSide:Play()--PlayTween

local function TeleportToGame(GameID)
  TeleportService:Teleport(GameID)
end

--PlayBtn 
PlayBtn.MouseEnter:Connect(function()
    HoverOverPlayBtn:Play()
end)
PlayBtn.MouseLeave:Connect(function()
    LeavePlayBtn:Play()
end)
PlayBtn.MouseButton1Click:Connect(function()

    GamePopin:Play()
    SlideInSide:Play()
    if ShopOpen then
      ShopPopout:Play()
    end
    wait(0.5)
    Sidebar:Destroy()
    ShopPopup:Destroy()

 local Success, Error = pcall(function()
    TeleportToGame(4845271643)
  end)


  repeat
    FT = FT + 1
    wait(5)
    Success, Error = pcall(function()
      TeleportToGame(4845271643)
    end)
  until Success or FT == 1

  if FT == 5 then
    Players.LocalPlayer:Kick("Problem Joining Game")
  elseif FT~= 5 and Success then
    warn("Success")
  end


Text1In:Play()
Text2In:Play()
Text3In:Play()
Text4In:Play()
Text5In:Play()
Trial1In:Play()
Trial2In:Play()
Trial3In:Play()
Trial4In:Play()
Trial5In:Play()
ReturnIn:Play()

--ShopBtn
ShopBtn.MouseEnter:Connect(function()
    HoverOverShopBtn:Play()
end)
ShopBtn.MouseLeave:Connect(function()
    LeaveShopBtn:Play()
end)
ShopBtn.MouseButton1Click:Connect(function()
    if not ShopOpen then
        ShopOpen = true
        ShopPopin:Play()
        wait(0.3)
        for i,v in pairs(ShopPopup:GetDescendants())do
            if v.IsA("TextLabel")then
            v.Visible = true
          end
        end
    else
       for i,v in pairs(ShopPopup:GetDescendants())do
          if v.IsA("TextLabel")then
              v.Visible = false
          end
        end
        ShopPopout:Play()
        ShopOpen = false
        wait(0.3)
    end
end)
end

First of all I will explain what an 'end' is, it basically tells the script that you are finished with that function or statement. To finish statements you use a normal 'end', to finish connect functions you use a 'end)' with a bracket. Let me explain a bit more:

if 1 + 1 == 3 then -- A simple if statement
print("3")
end -- If we removed this end, (which tells the script the closest thing is finished, i.e the if statement) then the answer to the first if statement would be false, BUT the second one wouldn't run because the first one is false. When we add the end there it tells the script that it is finished, and the second if statement is a completely different statement. In studio on the left of when in a script arrows pop up when making functions and if statements, you can open and close these arrows to show what controls what, and what runs off of what.
if 2 + 2 == 4 then 
print("4")
end

An end relates to the closest code passage, e.g

while true do
if 1 + 1 == 2 then
wait(1)
end -- This closes the if statement
print("1") -- You'll notice this will continue because it is still running off of the while true do
end -- Closing the while true do

Now to depict your error:

Players.Westleys_Peaches.PlayerGui.Menu.MenuMain:143: - This shows you where it is, and what line you need to fix

Expected 'end' (to close 'function' at line 73), got " - This tells us what the error is and where it happened, in this case you forgot to close the function at line 73, eof pretty much means nil or nothing.

I hope I helped, if I did please accept this answer, I suggest you look at the wikis, they have some very useful info.

2 comments

0

I can't thank you enough! I'm realizing now how simple the error was, but I'm glad that it's finally resolved. Also, thank you for going into detail on what I did wrong. That really helps to clear things up so I wont repeat this error!

0

I'm glad I helped! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.