Something isn't quite right

Hey everybody!
I need help with my scripting. I have just started a few months ago, and no pro, so please don’t go at me too hard.
I am making a sessions booking board and I can’t figure out how many ends’ I need! Can somebody please tell me? Here’s the code:

	Player.Chatted:Connect(function(Message)
		if Message == "!book" then
			if Player:GetRankInGroup(5974444) >= 17 then
				Player.PlayerGui.ScreenGui.SessionType.Visible = true
				Player.PlayerGui.ScreenGui.BackgroundFade.Visible = true
				Player.PlayerGui.ScreenGui.DSL.Visible = true
				Player.PlayerGui.ScreenGui.DSLtwo.Visible = true
			if Player.PlayerGui.ScreenGui.SessionType.Interview.MouseButton1Click:Connect(function(player)
				Player.PlayerGui.ScreenGui.SessionTime.Visible = true
			if Player.PlayerGui.ScreenGui.SessionTime.Next.MouseButton1Click:Connect(function(player)
				Player.PlayerGui.ScreenGui.SessionTime.Visible = false
								if Player.PlayerGui.ScreenGui.SessionTime.twoAMEST.MouseButton1Click:Connect(function(player)
										Player.PlayerGui.ScreenGui.Overview.TimeConfirm.MouseButton1Click:Connect(function(player)
											Player.PlayerGui.ScreenGui.Overview.TimeConfirm.Text = "2 AM EST"
											if Player.PlayerGui.ScreenGui.SessionTime.Next.MouseButton1Click:Connect(function(player)
													Player.PlayerGui.Overview.Visible = true```

Thank you! (I know it's lay out weirdly, I am doing some early testing, so please just try and work it out from the script.)

Please, please, please, format your code when you ask a scripting question.

1 Like

So I decided to format your code and it turned into this:

1)Let’s start with lines like if Player.PlayerGui.ScreenGui.SessionType.Interview.MouseButton1Click:Connect().
First of all, that’s not how events work. You don’t use events in a if statement like that. You use events to fire a function when something specific happens. :Connect() doesn’t return anything except for the script signal itself.

2)You wrote Player.PlayerGui.ScreenGui a lot of times when you could’ve attached it to a variable like this:

local ScreenGui = Player.PlayerGui.ScreenGui

With these problems in mind, I decided to rewrote your code with comments explaining what’s going on more clearly for you to understand:

game.Players.PlayerAdded:Connect(function(Player)
	local ScreenGui = Player.PlayerGui.ScreenGui -- Declare "ScreenGui" as a reference to "Player.PlayerGui.ScreenGui" so you don't have to write that long thing everytime
	Player.Chatted:Connect(function(Message) 
		if Message == "!book" and Player:GetRankInGroup(5974444) >= 17 then --Checks if message is equal to "!book" AND if player's rank in specified group is 17 or above, if it is, executes the code inside it.
			ScreenGui.SessionType.Visible = true 
			ScreenGui.BackgroundFade.Visible = true 
			ScreenGui.DSL.Visible = true 
			ScreenGui.DSLtwo.Visible = true 
			ScreenGui.SessionType.Interview.MouseButton1Click:Connect(function(player) --This function runs every time someone clicks on the "Player.PlayerGui.ScreenGui.SessionType.Interview" with left mouse button.
				Player.PlayerGui.ScreenGui.SessionTime.Visible = true 
			end)
			ScreenGui.SessionTime.Next.MouseButton1Click:Connect(function(player) --This function runs every time someone clicks on the "Player.PlayerGui.ScreenGui.SessionTime.Next" with left mouse button.
				Player.PlayerGui.ScreenGui.SessionTime.Visible = false
			end)
			ScreenGui.Overview.TimeConfirm.MouseButton1Click:Connect(function(player) --This function runs every time someone clicks on the "Player.PlayerGui.ScreenGui.Overview.TimeConfirm" with left mouse button.
				ScreenGui.Overview.TimeConfirm.Text = "2 AM EST" 
			end)
			ScreenGui.SessionTime.Next.MouseButton1Click:Connect(function(player) --This function runs every time someone clicks on the "Player.PlayerGui.ScreenGui.SessionTime.Next" with left mouse button.
				Player.PlayerGui.Overview.Visible = true
			end)
			
		end 	
	end)
end) 
1 Like

I did, when I pasted it into the forum post it didn’t format.

you have too type

-- your code here

```
– your code here
```

to format it

ok well you never put an end for each if statement

So… I get an error:
"ScreenGui is not a valid member of PlayerGui “Players.Skarvul.PlayerGui”
Please help me…

Are you cloning the GUI into the LocalPlayer’s PlayerGUI?