---------------------------------------------------------------------------------------

playButton.Button.MouseButton1Click:Connect(function()
	buttonsClose:Play()
	titleClose:Play()
	popupsClose:Play()
	fadeClose:Play()
	blurClose:Play()
	versionClose:Play()
	menuMusicOff:Play()
	wait(longLength)
	currentCamera.CameraType = Enum.CameraType.Custom
	currentCamera.CameraSubject = game.Workspace[player.Name]:WaitForChild("Humanoid")
	wait(shortLength)
	clickedPlayButton:FireServer(player.Name)
	fadeOpen:Play()
	Sounds.MenuMusic.Playing = false
	Sounds.GameMusic.Playing = configuration.GameMusic.Value
	gameMusicOn:Play()
	configuration.MenuMusicVolume.Value = customMenuMusicVolume
	configuration.GameMusicVolume.Value = customGameMusicVolume
	gameFieldOfViewChange = ts:Create(currentCamera, ti2, {FieldOfView = configuration.FieldOfView.Value})
	gameFieldOfViewChange:Play()
	game.Lighting.Blur.Enabled = configuration.Blur.Value
	game.Lighting.DepthOfField.Enabled = configuration.DepthOfField.Value
	game.Lighting.SunRays.Enabled = configuration.Sunrays.Value
	game.Lighting.ColorCorrection.Enabled = configuration.ColorCorrection.Value
	game.Lighting.Bloom.Enabled = configuration.Bloom.Value
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, true)
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end)

settingsButton.Button.MouseButton1Click:Connect(function()
	if popupsAreOpen.Value == false then
		buttonsClose:Play()
		titleClose:Play()
		settingsPopup.Visible = true
		wait(0.5)
		popupsOpen:Play()
		wait(0.85)
		popupsAreOpen.Value = true
	end
end)

infoButton.Button.MouseButton1Click:Connect(function()
	if popupsAreOpen.Value == false then
		buttonsClose:Play()
		titleClose:Play()
		infoPopup.Visible = true
		wait(0.5)
		popupsOpen:Play()
		wait(0.85)
		popupsAreOpen.Value = true
	end
end)

creditsButton.Button.MouseButton1Click:Connect(function()
	if popupsAreOpen.Value == false then
		buttonsClose:Play()
		titleClose:Play()
		creditsPopup.Visible = true
		wait(0.5)
		popupsOpen:Play()
		wait(0.85)
		popupsAreOpen.Value = true
	end
end)

shopButton.Button.MouseButton1Click:Connect(function()
	if popupsAreOpen.Value == false then
		buttonsClose:Play()
		titleClose:Play()
		shopPopup.Visible = true
		wait(0.5)
		popupsOpen:Play()
		wait(0.85)
		popupsAreOpen.Value = true
	end
end)

game.ReplicatedStorage.CharacterDied.OnClientEvent:Connect(function(plr)
	if plr == player.Name then
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
		game.Lighting.Blur.Enabled = true
		fadeClose:Play()
		gameMusicOff:Play()
		wait(longLength)
		currentCamera.FieldOfView = customMenuFieldOfView
		currentCamera.CameraType = Enum.CameraType.Scriptable
		currentCamera.CFrame = spawnItems.CameraPart.CFrame
		game.Lighting.DepthOfField.Enabled = true
		game.Lighting.SunRays.Enabled = true
		game.Lighting.ColorCorrection.Enabled = true
		game.Lighting.Bloom.Enabled = true
		wait(shortLength)
		versionOpen:Play()
		fadeOpen:Play()
		blurOpen:Play()
		Sounds.GameMusic.Playing = false
		Sounds.MenuMusic.Playing = configuration.GameMusic.Value
		menuMusicOn:Play()
		configuration.MenuMusicVolume.Value = customMenuMusicVolume
		configuration.GameMusicVolume.Value = customGameMusicVolume
		wait(shortLength)
		buttonsOpen:Play()
		titleOpen:Play()
	end
end)